284 lines
9.2 KiB
PHP
284 lines
9.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
if (!defined('sugarEntry') || !sugarEntry)
|
||
|
|
die('Not A Valid Entry Point');
|
||
|
|
|
||
|
|
global $sugar_config, $current_user, $mod_strings, $current_user, $app_list_strings;
|
||
|
|
|
||
|
|
include_once('modules/EcmQuotes/EcmQuote.php');
|
||
|
|
require_once('modules/EcmServices/EcmService.php');
|
||
|
|
require_once('modules/EcmServices/Forms.php');
|
||
|
|
require_once('include/json_config.php');
|
||
|
|
|
||
|
|
$json_config = new json_config();
|
||
|
|
|
||
|
|
$file = 'modules/EcmGroupServices/EcmGroupService.php';
|
||
|
|
|
||
|
|
if (file_exists($file)) {
|
||
|
|
$cc = array();
|
||
|
|
require_once($file);
|
||
|
|
$cc = EcmGroupService::loadSettings();
|
||
|
|
}
|
||
|
|
|
||
|
|
$OPT = array();
|
||
|
|
|
||
|
|
$OPT['row_item_height'] = $cc['row_item_height'];
|
||
|
|
$OPT['row_item_height_selected'] = $cc['row_item_height_selected'];
|
||
|
|
$OPT['rows_on_item_list'] = $cc['rows_on_item_list'];
|
||
|
|
$OPT['position_table_height'] = $OPT['row_item_height'] * $OPT['rows_on_item_list'] + 40 + $OPT['rows_on_item_list'] * 4;
|
||
|
|
$OPT['quick_product_item_adding'] = $cc['quick_product_item_adding'];
|
||
|
|
$OPT['check_parent_id'] = true;
|
||
|
|
$cq = $current_user->getPreference('confirm_quotes');
|
||
|
|
$OPT['user']['confirm_quotes'] = ((isset($cq) && $cq) ? 1 : 0);
|
||
|
|
|
||
|
|
$focus = new EcmService();
|
||
|
|
|
||
|
|
$OPT['auto_commiting'] = $focus->ACLAccess('auto_commiting');
|
||
|
|
|
||
|
|
if (true) {
|
||
|
|
$OPT['new_number'] = true;
|
||
|
|
$focus->status = 'registered';
|
||
|
|
|
||
|
|
if (isset($cc)) {
|
||
|
|
//payment condition
|
||
|
|
$cc_list = EcmGroupService::getPositionList('ecmpaymentconditions');
|
||
|
|
$focus->ecmpaymentcondition_id = $cc['default_payment_condition'];
|
||
|
|
$focus->ecmpaymentcondition_name = $cc_list[$cc['default_payment_condition']];
|
||
|
|
|
||
|
|
//delivery condition
|
||
|
|
$cc_list = EcmGroupService::getPositionList('ecmdeliveryconditions');
|
||
|
|
$focus->ecmdeliverycondition_id = $cc['default_delivery_condition'];
|
||
|
|
$focus->ecmdeliverycondition_name = $cc_list[$cc['default_delivery_condition']];
|
||
|
|
|
||
|
|
//default template
|
||
|
|
$focus->template_id = $cc['default_document_template'];
|
||
|
|
$fftemplateid = $focus->template_id;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($_REQUEST['ecmquote_id']) {
|
||
|
|
$quo = new EcmQuote();
|
||
|
|
$quo->retrieve($_REQUEST['ecmquote_id']);
|
||
|
|
|
||
|
|
$arr = array(
|
||
|
|
'parent_id',
|
||
|
|
'parent_name',
|
||
|
|
'status',
|
||
|
|
'name',
|
||
|
|
'register_date',
|
||
|
|
'currency_id',
|
||
|
|
'template_id',
|
||
|
|
'validtill_date',
|
||
|
|
'is_vat_free',
|
||
|
|
'to_vatid',
|
||
|
|
'ecmlanguage',
|
||
|
|
'parent_address_street',
|
||
|
|
'parent_address_city',
|
||
|
|
'parent_address_postalcode',
|
||
|
|
'parent_address_country',
|
||
|
|
'parent_name_copy',
|
||
|
|
'parent_contact_name',
|
||
|
|
'parent_contact_title',
|
||
|
|
'show_primary_params',
|
||
|
|
'show_advanced_params',
|
||
|
|
);
|
||
|
|
|
||
|
|
foreach ($arr as $a) {
|
||
|
|
$focus->$a = $quo->$a;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
$OPT['user']['access']['send_email'] = $focus->ACLAccess('send_email');
|
||
|
|
$OPT['old_status'] = (isset($focus->status) && $focus->status != '') ? $focus->status : 'not_accepted';
|
||
|
|
|
||
|
|
if ($_REQUEST['isDuplicate'] == 'true') {
|
||
|
|
$_POST['isDuplicate'] = true;
|
||
|
|
$focus->id = '';
|
||
|
|
$OPT['isDuplicate'] = ture;
|
||
|
|
$OPT['new_number'] = true;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!isset($focus->discount) || $focus->discount == '')
|
||
|
|
$focus->discount = 0.00;
|
||
|
|
|
||
|
|
if ($OPT['new_number'] == true) {
|
||
|
|
$datef = $current_user->getPreference('datef');
|
||
|
|
|
||
|
|
if ($datef != '')
|
||
|
|
$sugar_config['datef'];
|
||
|
|
|
||
|
|
$focus->register_date = date($datef);
|
||
|
|
$focus->payment_date = date($datef, mktime() + 30 * 24 * 60 * 60);
|
||
|
|
$focus->sell_date = date($datef);
|
||
|
|
}
|
||
|
|
|
||
|
|
$tmp = $current_user->getPreference('num_grp_sep');
|
||
|
|
|
||
|
|
if (!isset($tmp) || $tmp == '' || $tmp == NULL)
|
||
|
|
$tmp = $sugar_config['default_number_grouping_seperator'];
|
||
|
|
|
||
|
|
$OPT['sep_1000'] = $tmp;
|
||
|
|
|
||
|
|
$tmp = $current_user->getPreference('dec_sep');
|
||
|
|
|
||
|
|
if (!isset($tmp) || $tmp == '' || $tmp == NULL)
|
||
|
|
$tmp = $sugar_config['default_decimal_seperator'];
|
||
|
|
|
||
|
|
$OPT['dec_sep'] = $tmp;
|
||
|
|
|
||
|
|
$tmp = $current_user->getPreference('default_currency_significant_digits');
|
||
|
|
|
||
|
|
if (!isset($tmp) || $tmp == '' || $tmp == NULL)
|
||
|
|
$tmp = $sugar_config['default_currency_significant_digits'];
|
||
|
|
|
||
|
|
$OPT['dec_len'] = $tmp;
|
||
|
|
|
||
|
|
$OPT['default_unit'] = 'SZT.';
|
||
|
|
$OPT['default_vat'] = '23.00';
|
||
|
|
$OPT['default_category'] = '';
|
||
|
|
$OPT['default_currency'] = '-99';
|
||
|
|
$OPT['type'] = $focus->type;
|
||
|
|
$OPT['to_is_vat_free'] = $focus->to_is_vat_free;
|
||
|
|
|
||
|
|
require_once('modules/EcmTexts/EcmText.php');
|
||
|
|
foreach ($app_list_strings['ecmlanguages_dom'] as $key => $value) {
|
||
|
|
$data = EcmText::LoadText(null, null, 'EcmServices', $key);
|
||
|
|
if (isset($data[0]) && isset($data[0]['data']))
|
||
|
|
$d = $data[0]['data']; else {
|
||
|
|
$d = $PDFLL;
|
||
|
|
if (!isset($d['labels']))
|
||
|
|
$d['labels'] = $PDFLL['labels'];
|
||
|
|
|
||
|
|
if (!isset($d['texts']['Contacts']['header_text']))
|
||
|
|
$d['texts']['Contacts']['header_text'] = $mod_strings['LBL_DEFAULT_CONTACT_HEADER_TEXT'];
|
||
|
|
|
||
|
|
if (!isset($d['texts']['Contacts']['footer_text']))
|
||
|
|
$d['texts']['Contacts']['footer_text'] = $mod_strings['LBL_DEFAULT_CONTACT_FOOTER_TEXT'];
|
||
|
|
|
||
|
|
if (!isset($d['texts']['Contacts']['ads_text']))
|
||
|
|
$d['texts']['Contacts']['ads_text'] = $mod_strings['LBL_DEFAULT_CONTACT_ADS_TEXT'];
|
||
|
|
|
||
|
|
if (!isset($d['texts']['Accounts']['header_text']))
|
||
|
|
$d['texts']['Accounts']['header_text'] = $mod_strings['LBL_DEFAULT_ACCOUNT_HEADER_TEXT'];
|
||
|
|
|
||
|
|
if (!isset($d['texts']['Accounts']['footer_text']))
|
||
|
|
$d['texts']['Accounts']['footer_text'] = $mod_strings['LBL_DEFAULT_ACCOUNT_FOOTER_TEXT'];
|
||
|
|
|
||
|
|
if (!isset($d['texts']['Accounts']['ads_text']))
|
||
|
|
$d['texts']['Accounts']['ads_text'] = $mod_strings['LBL_DEFAULT_ACCOUNT_ADS_TEXT'];
|
||
|
|
}
|
||
|
|
$OPT['ecmlanguage'][$key]['texts'] = $d['texts'];
|
||
|
|
}
|
||
|
|
|
||
|
|
$show_pdf = $current_user->getPreference('show_pdf_in_div');
|
||
|
|
if (!isset($show_pdf)) {
|
||
|
|
require_once('modules/EcmGroupServices/EcmGroupService.php');
|
||
|
|
$cc = EcmGroupService::loadSettings();
|
||
|
|
$show_pdf = $cc['show_pdf_in_div_global'];
|
||
|
|
}
|
||
|
|
|
||
|
|
$w = $GLOBALS[db]->query('select name,id,value from ecmvats where deleted=\'0\' order by name');
|
||
|
|
$nvats = mysql_num_rows($w);
|
||
|
|
while ($r = $GLOBALS[db]->fetchByAssoc($w)) {
|
||
|
|
$VAT[$r['id']] = array(
|
||
|
|
'id' => $r['id'],
|
||
|
|
'name' => $r['name'],
|
||
|
|
'value' => $r['value']
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
$json = getJSONobj();
|
||
|
|
$scriptOpt = '
|
||
|
|
<script language="javascript">
|
||
|
|
var VAT = ' . str_replace('"', '"', $json->encode($VAT)) . ';
|
||
|
|
var SHOW_PDF_IN_DIV = ' . $show_pdf . ';
|
||
|
|
var OPT = ' . str_replace('"', '"', $json->encode($OPT)) . ';
|
||
|
|
var MOD = ' . str_replace('"', '"', $json->encode($mod_strings)) . ';
|
||
|
|
var N; var N2; var N3;
|
||
|
|
</script>
|
||
|
|
';
|
||
|
|
|
||
|
|
echo $scriptOpt;
|
||
|
|
|
||
|
|
require_once('include/MVC/View/SugarView.php');
|
||
|
|
require_once('modules/EcmServices/views/CreateView/view.create.ecmservices.php');
|
||
|
|
|
||
|
|
$create = new ViewCreateEcmServices();
|
||
|
|
$create->ss = new Sugar_Smarty();
|
||
|
|
$create->module = 'EcmServices';
|
||
|
|
$create->bean = $focus;
|
||
|
|
$create->tplFile = 'include/ECM/EcmViews/CreateView/Tabs/CreateView.tpl';
|
||
|
|
|
||
|
|
|
||
|
|
// Build rw stock and pw stock option lists.
|
||
|
|
$w = $GLOBALS['db']->query("select name,id from ecmstocks where deleted='0' order by name asc");
|
||
|
|
|
||
|
|
$stock_id = ($focus->stock_id ? : $GLOBALS['app_list_strings']['ecmservices_stock_id_dom']);
|
||
|
|
$pw_stock_id = ($focus->pw_stock_id ? : $GLOBALS['app_list_strings']['ecmservices_pw_stock_id_dom']);
|
||
|
|
|
||
|
|
$stocks[] = $pw_stocks[] = '<option value="">' . $GLOBALS['app_list_strings']['stock_select'] . '</option>';
|
||
|
|
|
||
|
|
while ($r = $GLOBALS['db']->fetchByAssoc($w)) {
|
||
|
|
$option = '<option value="'. $r['id'] . '"%s>' . $r['name'] . '</option>';
|
||
|
|
|
||
|
|
$stock_selected = $r['id'] == $stock_id;
|
||
|
|
$pw_stock_selected = $r['id'] == $pw_stock_id;
|
||
|
|
|
||
|
|
array_push($stocks , sprintf($option, $stock_selected ? ' selected' : ''));
|
||
|
|
array_push($pw_stocks , sprintf($option, $pw_stock_selected ? ' selected' : ''));
|
||
|
|
}
|
||
|
|
|
||
|
|
$status = array();
|
||
|
|
|
||
|
|
foreach($app_list_strings['ecmservices_status_dom'] as $key => $value)
|
||
|
|
{
|
||
|
|
$option = '<option value="'. $key . '"%s>' . $value . '</option>';
|
||
|
|
|
||
|
|
$selected = ($key == $focus->status);
|
||
|
|
//var_dump($selected);
|
||
|
|
|
||
|
|
array_push($status , sprintf($option, $selected ? ' selected' : ''));
|
||
|
|
}
|
||
|
|
|
||
|
|
$create->ss->assign('STATUS', implode($status));
|
||
|
|
$create->ss->assign('STOCK', implode($stocks));
|
||
|
|
$create->ss->assign('PW_STOCK', implode($pw_stocks));
|
||
|
|
$create->ss->assign('OPT', $OPT);
|
||
|
|
|
||
|
|
$create->preDisplay();
|
||
|
|
|
||
|
|
// Build templates option list.
|
||
|
|
$arr_template = $focus->getTemplateList();
|
||
|
|
|
||
|
|
$tt = array();
|
||
|
|
|
||
|
|
foreach ($arr_template as $k => $v) {
|
||
|
|
$option = '<option value="'. $k . '"%s>' . $v . '</option>';
|
||
|
|
|
||
|
|
$selected = ($k == $focus->template_id);
|
||
|
|
|
||
|
|
array_push($tt , sprintf($option, $selected ? ' selected' : ''));
|
||
|
|
}
|
||
|
|
|
||
|
|
$create->ss->assign('DOCUMENT_TEMPLATES_OPTIONS', implode($tt));
|
||
|
|
|
||
|
|
if (count($_REQUEST['check']) > 0) {
|
||
|
|
foreach ($_REQUEST['check'] as $ch) {
|
||
|
|
$r = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query('select * from ecmquoteitems where id = \'' . $ch . '\''));
|
||
|
|
$pos = EcmQuote::getPosition($r);
|
||
|
|
$pos['item_id'] = $ch;
|
||
|
|
$ret[] = $pos;
|
||
|
|
}
|
||
|
|
//print_r($ret);die();
|
||
|
|
$focus->position_list = $json->encode($ret);
|
||
|
|
}
|
||
|
|
|
||
|
|
$temp_id = !$focus->id ? create_guid() : $focus->temp_id;
|
||
|
|
|
||
|
|
$create->ss->assign('TEMP_ID', $temp_id);
|
||
|
|
$create->ss->assign('INCOME_LIST', $focus->position_list);
|
||
|
|
//$create->ss->assign('POSITION_LIST', $focus->position_list);
|
||
|
|
//$create->ss->assign('SERVICES_LIST', $focus->services_list);
|
||
|
|
$create->ss->assign('MFP', $focus->loadParserArray());
|
||
|
|
|
||
|
|
echo $create->display();
|