Files

278 lines
13 KiB
PHP
Raw Permalink Normal View History

2025-05-12 15:44:39 +00:00
<?php
/*****************************************************************************
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
* Version 1.1 ("License"); You may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/rpl.php. Software distributed under the
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
* either express or implied.
*
* You may:
* a) Use and distribute this code exactly as you received without payment or
* a royalty or other fee.
* b) Create extensions for this code, provided that you make the extensions
* publicly available and document your modifications clearly.
* c) Charge for a fee for warranty or support or for accepting liability
* obligations for your customers.
*
* You may NOT:
* a) Charge for the use of the original code or extensions, including in
* electronic distribution models, such as ASP (Application Service
* Provider).
* b) Charge for the original source code or your extensions other than a
* nominal fee to cover distribution costs where such distribution
* involves PHYSICAL media.
* c) Modify or delete any pre-existing copyright notices, change notices,
* or License text in the Licensed Software
* d) Assert any patent claims against the Licensor or Contributors, or
* which would in any way restrict the ability of any third party to use the
* Licensed Software.
*
* You must:
* a) Document any modifications you make to this code including the nature of
* the change, the authors of the change, and the date of the change.
* b) Make the source code for any extensions you deploy available via an
* Electronic Distribution Mechanism such as FTP or HTTP download.
* c) Notify the licensor of the availability of source code to your extensions
* and include instructions on how to acquire the source code and updates.
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
* reproduce, perform, modify, sublicense, and distribute your extensions.
*
* The Original Code is: CommuniCore
* Olavo Farias
* 2006-04-7 olavo.farias@gmail.com
*
* The Initial Developer of the Original Code is CommuniCore.
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
* All Rights Reserved.
********************************************************************************/
include("modules/EcmProductB2Bs/moduleMenu.php");
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
function show_image($img)
{
if(is_file($img))
{
$obraz=@GetImageSize($img);
if($obraz[0]>=180)
{
$szerokosc=180;
$wysokosc=$obraz[1]*$szerokosc/$obraz[0];
}
else
{
$szerokosc=$obraz[0];
$wysokosc=$obraz[1];
}
$height=$obraz[1]+20;
$width=$obraz[0]+20;
return '<a style="cursor:pointer;" onclick="window.open(\''.$img.'\',\'Image\',\'height='.$height.',width='.$width.'\');"><img src="pic.php?p='.$img.'&w='.$szerokosc.'&h='.$wysokosc.'"></a>';
}
}
require_once('XTemplate/xtpl.php');
require_once('data/Tracker.php');
require_once('modules/EcmProductB2Bs/EcmProductB2B.php');
require_once('modules/EcmProductB2Bs/Forms.php');
require_once('include/DetailView/DetailView.php');
global $mod_strings;
global $app_strings;
$focus = new EcmProductB2B();
$detailView = new DetailView();
$offset = 0;
// ONLY LOAD A RECORD IF A RECORD ID IS GIVEN;
// A RECORD ID IS NOT GIVEN WHEN VIEWING IN LAYOUT EDITOR
if (isset($_REQUEST['offset']) or isset($_REQUEST['record'])) {
$result = $detailView->processSugarBean("ECMPRODUCTS", $focus, $offset);
if($result == null) {
sugar_die($app_strings['ERROR_NO_RECORD']);
}
$focus = $result;
}else{
header("Location: index.php?module={EcmProductB2Bs}&action=index");
}
if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
$focus->id = "";
}
echo "\n<p>\n";
echo get_module_title($mod_strings['LBL_MODULE_ID'], $mod_strings['LBL_MODULE_NAME'].": ".$focus->name, true);
echo "\n</p>\n";
global $theme;
$theme_path = "themes/".$theme."/";
$image_path = $theme_path."images/";
require_once($theme_path.'layout_utils.php');
$GLOBALS['log']->info("EcmProductB2Bs detail view");
$focus->format_all_fields();
$xtpl=new XTemplate ('modules/EcmProductB2Bs/DetailView.html');
$xtpl->assign("MOD", $mod_strings);
$xtpl->assign("APP", $app_strings);
$xtpl->assign("THEME", $theme);
$xtpl->assign("GRIDLINE", $gridline);
$xtpl->assign("IMAGE_PATH", $image_path);
$xtpl->assign("PRINT_URL", "index.php?".$GLOBALS['request_string']);
$xtpl->assign("ID", $focus->id);
$xtpl->assign("ASSIGNED_TO", $focus->assigned_user_name);
$xtpl->assign("NAME", $focus->name);
$xtpl->assign("DATE_ENTERED", $focus->date_entered);
$xtpl->assign("DATE_MODIFIED", $focus->date_modified);
$xtpl->assign("CODE", $focus->code);
$xtpl->assign("PRODUCT_CATEGORY_ID", $focus->product_category_id);
$xtpl->assign("PRODUCT_CATEGORY", $focus->product_category);
$xtpl->assign("PRODUCT_LINE_ID", $focus->product_line_id);
$xtpl->assign("PRODUCT_LINE", $focus->product_line);
$xtpl->assign("MANUFACTURER_ID", $focus->manufacturer_id);
$xtpl->assign("MANUFACTURER", $focus->manufacturer);
$xtpl->assign("CONTACT_ID", $focus->contact_id);
$xtpl->assign("CONTACT_NAME", $focus->contact_name);
$xtpl->assign("VENDOR_ID", $focus->vendor_id);
$xtpl->assign("VENDOR_NAME", $focus->vendor_name);
$xtpl->assign("VENDOR_PART_NO", $focus->vendor_part_no);
if ($focus->product_active == '1') $xtpl->assign('PRODUCT_ACTIVE', "checked");
$xtpl->assign("SALES_START_DATE", $focus->sales_start_date);
$xtpl->assign("SALES_END_DATE", $focus->sales_end_date);
$xtpl->assign("PARENT_TYPE", $focus->parent_type);
$xtpl->assign("PARENT_ID", $focus->parent_id);
$xtpl->assign("PARENT_NAME", $focus->parent_name);
$xtpl->assign("WEBSITE", $focus->website);
$xtpl->assign("PART_NO", $focus->part_no);
$xtpl->assign("SERIAL_NO", $focus->serial_no);
$xtpl->assign("EXCHANGE_RATE_ID", $focus->exchange_rate_id);
$xtpl->assign("EXCHANGE_RATE_NAME", $focus->exchange_rate_name);
$xtpl->assign("FOB_PRICE", $focus->fob_price);
$xtpl->assign("PURCHASE_PRICE", $focus->purchase_price);
$xtpl->assign("SELLING_PRICE", $focus->selling_price);
$xtpl->assign("EMS_PRICE", $focus->ems_price);
$xtpl->assign("COMMISSION_RATE", $focus->commission_rate);
$xtpl->assign("CUSTOM_DUTY_RATE", $focus->custom_duty_rate);
$xtpl->assign("SRP_PRICE", $focus->srp_price);
$xtpl->assign("SRP_PROMO_PRICE", $focus->srp_promo_price);
$xtpl->assign("TAX_CLASS_ID", $focus->vat_id);
$xtpl->assign("TAX_CLASS_NAME", $focus->vat_name);
$xtpl->assign("USAGE_UNIT_ID", $focus->usage_unit_id);
$xtpl->assign("USAGE_UNIT_NAME", $focus->usage_unit_name);
$xtpl->assign("EMS_QTY_IN_STOCK", $focus->ems_qty_in_stock);
$xtpl->assign("SALES_LAST_MONTH_1", $focus->sales_last_month_1);
$xtpl->assign("SALES_LAST_MONTH", $focus->sales_last_month);
$xtpl->assign("SALES_THIS_MONTH", $focus->sales_this_month);
$xtpl->assign("QTY_PER_UNIT", $focus->qty_per_unit);
$xtpl->assign("AVERAGE_SALE_3_MONTHS", $focus->average_sale_3_months);
$xtpl->assign("SALES_PLUS_1", $focus->sales_plus_1);
$xtpl->assign("SALES_PLUS_2", $focus->sales_plus_2);
$xtpl->assign("SALES_PLUS_3", $focus->sales_plus_3);
$xtpl->assign("PRODUCT_PICTURE", show_image("modules/EcmProductB2Bs/upload/images/".$focus->product_picture));
$xtpl->assign("PACKING_FRONT_PICTURE", show_image("modules/EcmProductB2Bs/upload/images/".$focus->packing_front_picture));
$xtpl->assign("DRIVER_1", $focus->driver_1);
if($focus->driver_1)$xtpl->assign("DRIVER_1_DOWNLOAD",'<a href="modules/EcmProductB2Bs/upload/'.$focus->driver_1.'">Download</a>');
$xtpl->assign("DRIVER_2", $focus->driver_2);
if($focus->driver_2)$xtpl->assign("DRIVER_2_DOWNLOAD",'<a href="modules/EcmProductB2Bs/upload/'.$focus->driver_2.'">Download</a>');
$xtpl->assign("MOQ", $focus->moq);
$xtpl->assign("FOB_BASIS_ID", $focus->fob_basis_id);
$xtpl->assign("FOB_BASIS_NAME", $focus->fob_basis_name);
$xtpl->assign("DELIVERY_TIME_FOB", $focus->delivery_time_fob);
$xtpl->assign("PIECES_PER_CARTON", $focus->pieces_per_carton);
$xtpl->assign("PRODUCT_NETTO_WEIGHT", $focus->product_netto_weight);
$xtpl->assign("PRODUCT_BRUTTO_WEIGHT", $focus->product_brutto_weight);
$xtpl->assign("PACKING_TYPE_ID", $focus->packing_type_id);
$xtpl->assign("PACKING_TYPE_NAME", $focus->packing_type_name);
$xtpl->assign("PACKING_DIMENSIONS_1", $focus->packing_dimensions_1);
$xtpl->assign("PACKING_DIMENSIONS_2", $focus->packing_dimensions_2);
$xtpl->assign("PACKING_DIMENSIONS_3", $focus->packing_dimensions_3);
$xtpl->assign("RMA", $focus->rma);
$xtpl->assign("CARTON_DIMENSIONS_1", $focus->carton_dimensions_1);
$xtpl->assign("CARTON_DIMENSIONS_2", $focus->carton_dimensions_2);
$xtpl->assign("CARTON_DIMENSIONS_3", $focus->carton_dimensions_3);
$xtpl->assign("CARTON_NETTO_WEIGHT", $focus->carton_netto_weight);
$xtpl->assign("CARTON_BRUTTO_WEIGHT", $focus->carton_brutto_weight);
$xtpl->assign("CARTON_VOLUME_METER", $focus->carton_volume_meter);
$xtpl->assign("CARTON_VOLUME_FEET", $focus->carton_volume_feet);
$xtpl->assign("COUNTRY_OF_ORIGIN", $focus->country_of_origin);
$xtpl->assign("EMS_ORDERED", $focus->ems_ordered);
$st='';
$w=$GLOBALS['db']->query("select id,name from ecmstocks where deleted='0' order by name asc");
while($r=$GLOBALS['db']->fetchByAssoc($w))
{
$st.='<option value="'.$r['id'].'">'.$r['name'].'</option>';
}
$xtpl->assign("STOCK_INFO", $st);
require_once('modules/Currencies/Currency.php');
$currency = new Currency();
if(isset($focus->exchange_rate_id) && !empty($focus->exchange_rate_id))
{
$currency->retrieve($focus->exchange_rate_id);
if( $currency->deleted != 1){
$xtpl->assign("CURRENCY", $currency->iso4217 .' '.$currency->symbol );
}else $xtpl->assign("CURRENCY", $currency->getDefaultISO4217() .' '.$currency->getDefaultCurrencySymbol() );
}else{
$xtpl->assign("CURRENCY", $currency->getDefaultISO4217() .' '.$currency->getDefaultCurrencySymbol() );
}
include("modules/EcmDocs/Pagination.php");
$xtpl->assign("PAGINATION1",getPagination("ecmproducts","EcmProductB2Bs",$_REQUEST['record']));
if ($focus->certificate_of_origin == '1') $xtpl->assign('CERTIFICATE_OF_ORIGIN', "checked");
if ($focus->form_a == '1') $xtpl->assign('FORM_A', "checked");
global $db;
$result = $GLOBALS['db']->query("select ean,remarks,short_description,long_description,language from ecmproduct_language where ecmproduct_id='".$_REQUEST['record']."'");
while($row=$GLOBALS['db']->fetchByAssoc($result))
{
$xtpl->assign("EAN_".$row['language'],$row['ean']);
$xtpl->assign("REMARKS_".$row['language'],$row['remarks']);
$xtpl->assign("SHORT_DESCRIPTION_".$row['language'],$row['short_description']);
$xtpl->assign("LONG_DESCRIPTION_".$row['language'],$row['long_description']);
}
global $current_user;
if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){
$xtpl->assign("ADMIN_EDIT","<a href='index.php?action=index&module=DynamicLayout&from_action=".$_REQUEST['action'] ."&from_module=".$_REQUEST['module'] ."&record=".$_REQUEST['record']. "'>".get_image($image_path."EditLayout","border='0' alt='Edit Layout' align='bottom'")."</a>");
}
$xtpl->assign("CREATED_BY", $focus->created_by_name);
$xtpl->assign("MODIFIED_BY", $focus->modified_by_name);
$detailView->processListNavigation($xtpl, "ECMPRODUCTS", $offset, $focus->is_AuditEnabled());
// ADDING CUSTOM FIELDS:
require_once('modules/DynamicFields/templates/Files/DetailView.php');
if(!empty($focus->id)) {
$merge_button = <<<EOQ
<input title="{$app_strings['LBL_DUP_MERGE']}" accessKey="M" class="button" onclick="this.form.return_module.value='EcmProductB2Bs'; this.form.return_action.value='DetailView';this.form.return_id.value='{$focus->id}'; this.form.action.value='Step1'; this.form.module.value='MergeRecords';" type="submit" name="Merge" value=" {$app_strings['LBL_DUP_MERGE']} "/>
EOQ;
$xtpl->assign("FIND_DUPES_MERGE_BUTTON", $merge_button);
}
$xtpl->parse("main");
$xtpl->out("main");
$sub_xtpl = $xtpl;
$old_contents = ob_get_contents();
ob_end_clean();
ob_start();
echo $old_contents;
require_once('modules/SavedSearch/SavedSearch.php');
$savedSearch = new SavedSearch();
$json = getJSONobj();
$savedSearchSelects = $json->encode(array($GLOBALS['app_strings']['LBL_SAVED_SEARCH_SHORTCUT'] . '<br>' . $savedSearch->getSelect('EcmProductB2Bs')));
$str = "<script>
YAHOO.util.Event.addListener(window, 'load', SUGAR.util.fillShortcuts, $savedSearchSelects);
</script>";
echo $str;
require_once('include/SubPanel/SubPanelTiles.php');
$subpanel = new SubPanelTiles($focus, "EcmProductB2Bs");
echo $subpanel->display();
?>