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 = ' '; 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[] = ''; while ($r = $GLOBALS['db']->fetchByAssoc($w)) { $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 = ''; $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 = ''; $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();