From 85059e2534d15a92cb370131657d232c6ef2aab6 Mon Sep 17 00:00:00 2001
From: yogeshwar <yogeshwar.g@vtigersolutions.com>
Date: Tue, 28 May 2024 14:47:51 +0530
Subject: [PATCH] E-all Inventory Modules

---
 include/utils/InventoryUtils.php                           | 1 +
 include/utils/VtlibUtils.php                               | 4 ++++
 layouts/v7/modules/Inventory/LineItemsDetail.tpl           | 4 ++--
 layouts/v7/modules/Inventory/partials/LineItemsEdit.tpl    | 2 +-
 layouts/v7/modules/PurchaseOrder/DetailViewHeaderTitle.tpl | 2 +-
 layouts/v7/modules/Vtiger/AddCommentForm.tpl               | 6 +++---
 layouts/v7/modules/Vtiger/ListViewQuickPreview.tpl         | 6 +++---
 modules/PurchaseOrder/PurchaseOrder.php                    | 2 +-
 modules/PurchaseOrder/actions/GetTaxes.php                 | 2 +-
 modules/Vtiger/views/ComposeEmail.php                      | 4 ++++
 10 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/include/utils/InventoryUtils.php b/include/utils/InventoryUtils.php
index 503f5f6b2..284914d25 100644
--- a/include/utils/InventoryUtils.php
+++ b/include/utils/InventoryUtils.php
@@ -427,6 +427,7 @@ function deleteInventoryProductDetails($focus)
 			}
 		}
 	}
+	$focus->update_product_array=isset($focus->update_product_array) ? $focus->update_product_array :''; //to avoid undefined property warning.
 	$updateInventoryProductRel_update_product_array = $focus->update_product_array;
     $adb->pquery("delete from vtiger_inventoryproductrel where id=?", array($focus->id));
     $adb->pquery("delete from vtiger_inventorysubproductrel where id=?", array($focus->id));
diff --git a/include/utils/VtlibUtils.php b/include/utils/VtlibUtils.php
index e8fb17dbf..66b34b89a 100644
--- a/include/utils/VtlibUtils.php
+++ b/include/utils/VtlibUtils.php
@@ -1057,3 +1057,7 @@ function php7_htmlentities($str) {
 function php_rand($int){
 	return $int == null ? $int : mt_rand($int,1000);
 }
+
+function php_imp($value){
+	return $value == null ? $value : implode(' ',$value);
+}
diff --git a/layouts/v7/modules/Inventory/LineItemsDetail.tpl b/layouts/v7/modules/Inventory/LineItemsDetail.tpl
index 9ca435fe5..d941506c2 100644
--- a/layouts/v7/modules/Inventory/LineItemsDetail.tpl
+++ b/layouts/v7/modules/Inventory/LineItemsDetail.tpl
@@ -39,7 +39,7 @@
     {assign var=QUANTITY_VIEWABLE value=$LINEITEM_FIELDS['quantity']->isViewable()}
 {if $QUANTITY_VIEWABLE}{assign var=COL_SPAN1 value=($COL_SPAN1)+1}{/if}
 {/if}
-{if $LINEITEM_FIELDS['purchase_cost']}
+{if isset($LINEITEM_FIELDS['purchase_cost']) && $LINEITEM_FIELDS['purchase_cost']}
     {assign var=PURCHASE_COST_VIEWABLE value=$LINEITEM_FIELDS['purchase_cost']->isViewable()}
 {if $PURCHASE_COST_VIEWABLE}{assign var=COL_SPAN2 value=($COL_SPAN2)+1}{/if}
 {/if}
@@ -47,7 +47,7 @@
     {assign var=LIST_PRICE_VIEWABLE value=$LINEITEM_FIELDS['listprice']->isViewable()}
 {if $LIST_PRICE_VIEWABLE}{assign var=COL_SPAN2 value=($COL_SPAN2)+1}{/if}
 {/if}
-{if $LINEITEM_FIELDS['margin']}
+{if isset($LINEITEM_FIELDS['margin']) && $LINEITEM_FIELDS['margin']}
     {assign var=MARGIN_VIEWABLE value=$LINEITEM_FIELDS['margin']->isViewable()}
 {if $MARGIN_VIEWABLE}{assign var=COL_SPAN3 value=($COL_SPAN3)+1}{/if}
 {/if}
diff --git a/layouts/v7/modules/Inventory/partials/LineItemsEdit.tpl b/layouts/v7/modules/Inventory/partials/LineItemsEdit.tpl
index 720cb04a2..fa74b5c65 100644
--- a/layouts/v7/modules/Inventory/partials/LineItemsEdit.tpl
+++ b/layouts/v7/modules/Inventory/partials/LineItemsEdit.tpl
@@ -185,7 +185,7 @@
 						{include file="partials/LineItemsContent.tpl"|@vtemplate_path:'Inventory' row_no=0 data=[] IGNORE_UI_REGISTRATION=true}
 					</tr>
 					{foreach key=row_no item=data from=$RELATED_PRODUCTS}
-						<tr id="row{$row_no}" data-row-num="{$row_no}" class="lineItemRow" {if isset($data["entityType$row_no"]) && $data["entityType$row_no"] eq 'Products'}data-quantity-in-stock={$data["qtyInStock$row_no"]}{/if}>
+						<tr id="row{$row_no}" data-row-num="{$row_no}" class="lineItemRow" {if isset($data["entityType$row_no"]) && $data["entityType$row_no"] eq 'Products'}data-quantity-in-stock={(isset($data["qtyInStock$row_no"])) ? $data["qtyInStock$row_no"] : ''}{/if}>
 							{include file="partials/LineItemsContent.tpl"|@vtemplate_path:'Inventory' row_no=$row_no data=$data}
 						</tr>
 					{/foreach}
diff --git a/layouts/v7/modules/PurchaseOrder/DetailViewHeaderTitle.tpl b/layouts/v7/modules/PurchaseOrder/DetailViewHeaderTitle.tpl
index 32f1128bd..752eb68c0 100644
--- a/layouts/v7/modules/PurchaseOrder/DetailViewHeaderTitle.tpl
+++ b/layouts/v7/modules/PurchaseOrder/DetailViewHeaderTitle.tpl
@@ -12,7 +12,7 @@
 {strip}
     <div class="col-lg-6 col-md-6 col-sm-6">
         <div class="record-header clearfix">
-            <div class="recordImage bgpurchaseorder app-{$SELECTED_MENU_CATEGORY}">
+            <div class="recordImage bgpurchaseorder app-{(isset($SELECTED_MENU_CATEGORY)) ? $SELECTED_MENU_CATEGORY : ''}">
                 {assign var=IMAGE_DETAILS value=$RECORD->getImageDetails()}
                 {foreach key=ITER item=IMAGE_INFO from=$IMAGE_DETAILS}
                     {if !empty($IMAGE_INFO.url)}
diff --git a/layouts/v7/modules/Vtiger/AddCommentForm.tpl b/layouts/v7/modules/Vtiger/AddCommentForm.tpl
index a3771e228..ebb4b5bf6 100644
--- a/layouts/v7/modules/Vtiger/AddCommentForm.tpl
+++ b/layouts/v7/modules/Vtiger/AddCommentForm.tpl
@@ -18,10 +18,10 @@
             <input type="hidden" name="viewname" value="{$CVID}" />
             <input type="hidden" name="selected_ids" value={ZEND_JSON::encode($SELECTED_IDS)}>
             <input type="hidden" name="excluded_ids" value={ZEND_JSON::encode($EXCLUDED_IDS)}>
-            <input type="hidden" name="search_key" value= "{$SEARCH_KEY}" />
+            <input type="hidden" name="search_key" value= "{(isset($SEARCH_KEY)) ? $SEARCH_KEY : ''}" />
             <input type="hidden" name="operator" value="{$OPERATOR}" />
-            <input type="hidden" name="search_value" value="{$ALPHABET_VALUE}" />
-            <input type="hidden" name="search_params" value='{Vtiger_Util_Helper::toSafeHTML(ZEND_JSON::encode($SEARCH_PARAMS))}' />
+            <input type="hidden" name="search_value" value="{(isset($ALPHABET_VALUE)) ? $ALPHABET_VALUE : ''}" />
+            <input type="hidden" name="search_params" value='{(isset($SEARCH_PARAMS)) ? Vtiger_Util_Helper::toSafeHTML(ZEND_JSON::encode($SEARCH_PARAMS)) : ''}' />
             <input type="hidden" name="tag_params" value={ZEND_JSON::encode($TAG_PARAMS)}>
 
             {assign var=HEADER_TITLE value={vtranslate('LBL_ADDING_COMMENT', $MODULE)}}
diff --git a/layouts/v7/modules/Vtiger/ListViewQuickPreview.tpl b/layouts/v7/modules/Vtiger/ListViewQuickPreview.tpl
index f03215f93..9e89ddb47 100644
--- a/layouts/v7/modules/Vtiger/ListViewQuickPreview.tpl
+++ b/layouts/v7/modules/Vtiger/ListViewQuickPreview.tpl
@@ -29,16 +29,16 @@
 
             <div class="quickPreviewActions clearfix">
                 <div class="btn-group pull-left">
-                    <button class="btn btn-success btn-xs" onclick="window.location.href = '{$RECORD->getFullDetailViewUrl()}&app={$SELECTED_MENU_CATEGORY}'">
+                    <button class="btn btn-success btn-xs" onclick="window.location.href = '{$RECORD->getFullDetailViewUrl()}&app={(isset($SELECTED_MENU_CATEGORY)) ? $SELECTED_MENU_CATEGORY : ''}'">
                        {vtranslate('LBL_VIEW_DETAILS', $MODULE_NAME)} 
                     </button>
                 </div>
                 {if $NAVIGATION}
                     <div class="btn-group pull-right">
-                        <button class="btn btn-default btn-xs" id="quickPreviewPreviousRecordButton" data-record="{$PREVIOUS_RECORD_ID}" data-app="{$SELECTED_MENU_CATEGORY}" {if empty($PREVIOUS_RECORD_ID)} disabled="disabled" {*{else} onclick="Vtiger_List_Js.triggerPreviewForRecord({$PREVIOUS_RECORD_ID})"*}{/if} >
+                        <button class="btn btn-default btn-xs" id="quickPreviewPreviousRecordButton" data-record="{$PREVIOUS_RECORD_ID}" data-app="{(isset($SELECTED_MENU_CATEGORY)) ? $SELECTED_MENU_CATEGORY : ''}" {if empty($PREVIOUS_RECORD_ID)} disabled="disabled" {*{else} onclick="Vtiger_List_Js.triggerPreviewForRecord({$PREVIOUS_RECORD_ID})"*}{/if} >
                             <i class="fa fa-chevron-left"></i>
                         </button>
-                        <button class="btn btn-default btn-xs" id="quickPreviewNextRecordButton" data-record="{$NEXT_RECORD_ID}" data-app="{$SELECTED_MENU_CATEGORY}" {if empty($NEXT_RECORD_ID)} disabled="disabled" {*{else} onclick="Vtiger_List_Js.triggerPreviewForRecord({$NEXT_RECORD_ID})"*}{/if}>
+                        <button class="btn btn-default btn-xs" id="quickPreviewNextRecordButton" data-record="{$NEXT_RECORD_ID}" data-app="{(isset($SELECTED_MENU_CATEGORY)) ? $SELECTED_MENU_CATEGORY : ''}" {if empty($NEXT_RECORD_ID)} disabled="disabled" {*{else} onclick="Vtiger_List_Js.triggerPreviewForRecord({$NEXT_RECORD_ID})"*}{/if}>
                             <i class="fa fa-chevron-right"></i>
                         </button>
                     </div>
diff --git a/modules/PurchaseOrder/PurchaseOrder.php b/modules/PurchaseOrder/PurchaseOrder.php
index 259e55f30..8e00b1198 100644
--- a/modules/PurchaseOrder/PurchaseOrder.php
+++ b/modules/PurchaseOrder/PurchaseOrder.php
@@ -112,7 +112,7 @@ class PurchaseOrder extends CRMEntity {
 		$updateInventoryProductRel_deduct_stock = false;
 
 		$requestProductIdsList = $requestQuantitiesList = array();
-		$totalNoOfProducts = $_REQUEST['totalProductCount'];
+		$totalNoOfProducts = isset($_REQUEST['totalProductCount']) ? $_REQUEST['totalProductCount'] : '';
 		for($i=1; $i<=$totalNoOfProducts; $i++) {
 			$productId = $_REQUEST['hdnProductId'.$i];
 			$requestProductIdsList[$productId] = $productId;
diff --git a/modules/PurchaseOrder/actions/GetTaxes.php b/modules/PurchaseOrder/actions/GetTaxes.php
index 19f8d026a..6c516263d 100644
--- a/modules/PurchaseOrder/actions/GetTaxes.php
+++ b/modules/PurchaseOrder/actions/GetTaxes.php
@@ -78,7 +78,7 @@ class PurchaseOrder_GetTaxes_Action extends Inventory_GetTaxes_Action {
 								'description'			=> $descriptionsList[$id],
 								'baseCurrencyId'		=> $baseCurrencyIdsList[$id],
 								'quantityInStock'		=> $quantitiesList[$id],
-								'imageSource'			=> $imageSourcesList[$id]
+								'imageSource'			=> isset($imageSourcesList[$id]) ? $imageSourcesList[$id] :''
 					);
 
 			$info[] = array($id => $resultData);
diff --git a/modules/Vtiger/views/ComposeEmail.php b/modules/Vtiger/views/ComposeEmail.php
index d66dec450..b26e682ff 100644
--- a/modules/Vtiger/views/ComposeEmail.php
+++ b/modules/Vtiger/views/ComposeEmail.php
@@ -205,6 +205,10 @@ class Vtiger_ComposeEmail_View extends Vtiger_Footer_View {
 			$to = $requestTo;
 		}
 
+		if(is_array($to)) {
+			$to = implode(',',$to);
+		}
+
 		$documentsModel = Vtiger_Module_Model::getInstance('Documents');
 		$documentsURL = $documentsModel->getInternalDocumentsURL();
 
-- 
GitLab