query($query); if(is_resource($result)) { $row = $GLOBALS['db']->fetchByAssoc($result); if(isset($row['count']) && is_numeric($row['count']=intval($row['count'])) && $row['count'] >= 10) $OPT['checkbox_demo'] = 1; } } //$OPT['default_manager_role_id'] = $cc['default_manager_role_id']; //$OPT['default_representative_role_id'] = $cc['default_representative_role_id']; //$OPT['default_representative_extra_role_id'] = $cc['default_representative_extra_role_id']; $OPT['check_parent_id'] = true; $cq = $current_user->getPreference('confirm_quotes'); $OPT['user']['confirm_quotes'] = ((isset($cq) && $cq)?1:0); $focus = new EcmInsideOrder(); $OPT['auto_commiting'] = $focus->ACLAccess('auto_commiting'); if(isset($_REQUEST['record'])) { $focus->retrieve($_REQUEST['record']); if(isset($focus->id) && $focus->id != '') { if($focus->accepted == 1) { echo 'You cannot edit this quote. This quote is accepted. return'; return; } $focus->format_all_fields(); $focus->position_list = str_replace('"','\"',$focus->getPositionList()); } } else { if(isset($_REQUEST['contact_id']) && $_REQUEST['contact_id'] != '' && isset($_REQUEST['contact_name']) && $_REQUEST['contact_name'] != '') { $_REQUEST['parent_type'] = 'Contacts'; $_REQUEST['parent_name'] = $_REQUEST['contact_name']; $_REQUEST['parent_id'] = $_REQUEST['contact_id']; $OPT['check_parent_id'] = false; } if(isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '' && isset($_REQUEST['account_name']) && $_REQUEST['account_name'] != '') { $_REQUEST['parent_type'] = 'Accounts'; $_REQUEST['parent_name'] = $_REQUEST['account_name']; $_REQUEST['parent_id'] = $_REQUEST['account_id']; $OPT['check_parent_id'] = false; } $OPT['new_number'] = true; //$focus->status = "s10"; if(isset($cc)) { //payment condition $cc_list = EcmGroupSale::getPositionList('ecmpaymentconditions'); $focus->ecmpaymentcondition_id = $cc['default_payment_condition']; $focus->ecmpaymentcondition_name = $cc_list[$cc['default_payment_condition']]; //delivery condition $cc_list = EcmGroupSale::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 access 'Delete' is avaible for user than he is Manager and he can confirm Quotes. $OPT['user']['access']['send_email'] = $focus->ACLAccess("send_email"); //$OPT['old_status'] = (isset($focus->status) && $focus->status != '')?$focus->status:'registered'; 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); } include_once("modules/EcmSales/productionHelper.php"); if($_GET['production']==1){ if(count($_REQUEST['check'])>0){ foreach($_REQUEST['check'] as $ch){ $return_array=array(); $rp=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select * from ecmproducts where id='".$ch."'")); $sales=getSalesLast3m($rp['id']); $guid=create_guid(); $return_array['id'] = $rp['id']; $return_array['code'] = $rp['code']; $return_array['name'] = $rp['name']; $return_array['quantity'] = floor($sales/2); $return_array['prod_quantity'] = ""; $return_array['price'] = $rp['ems_price']; $return_array['total'] = $rp['moq']*$rp['ems_price']; $return_array['component'] = ""; $return_array['component_quantity'] = ""; $return_array['product_id'] = ""; $return_array['guid'] = $guid; $rrr[]=$return_array; $wc=$GLOBALS['db']->query("select ecmproduct_id as product_id,ecmcomponent_id as id,name,code,quantity from ecmproductcomponents where ecmproduct_id='".$rp['id']."' and deleted='0'"); while($rc=$GLOBALS['db']->fetchByAssoc($wc)){ $return_array=array(); $return_array['id'] = $rc['product_id']; $return_array['code'] = $rc['code']; $return_array['name'] = $rc['name']; $return_array['quantity'] = $rp['moq']*$rc['quantity']; $return_array['prod_quantity'] = ""; $return_array['price'] = 0; $return_array['total'] = 0; $return_array['component'] = 1; $return_array['component_quantity'] = $rc['quantity']; $return_array['product_id'] = $rp['id']; $return_array['guid'] = $guid; $rrr[]=$return_array; } } $json = getJSONobj(); $focus->position_list = str_replace('"','\"',$json->encode($rrr)); } } $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'] = "1"; $OPT['default_vat'] = "19.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,"EcmInsideOrders",$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']; } $w=$GLOBALS['db']->query("select name,id,value from ecmvats where deleted='0' order by name"); while($r=$GLOBALS['db']->fetchByAssoc($w)){ $VAT[$r['id']]=array( "id"=>$r['id'], "name"=>$r['name'], "value"=>$r['value'] ); $nvats++; } $show_pdf=$current_user->getPreference('show_pdf_in_div'); if(!isset($show_pdf)){ require_once('modules/EcmGroupSales/EcmGroupSale.php'); $cc = EcmGroupSale::loadSettings(); $show_pdf=$cc['show_pdf_in_div_global']; } $json = getJSONobj(); $scriptOpt = ''; $larr=array("en_us","pl_pl","ge_ge"); foreach($larr as $la){ $lv=return_app_list_strings_language($la); $UNIT_LANG[$la]=$lv['ecmproducts_unit_dom']; } $scriptOpt.=''; echo $scriptOpt; require_once('include/MVC/View/SugarView.php'); require_once('modules/EcmInsideOrders/views/EditView/view.edit.ecminsideorders.php'); $edit = new ViewEditEcmInsideOrders(); $edit->ss = new Sugar_Smarty(); $edit->bean = $focus; $edit->tplFile = 'include/ECM/EcmViews/EditView/Tabs/EditView.tpl'; $edit->module = 'EcmInsideOrders'; $edit->ss->assign("OPT",$OPT); $edit->preDisplay(); //load currencies require_once('modules/Currencies/Currency.php'); $currency = new Currency(); $currency_list = $currency->get_full_list('name'); $currency->retrieve('-99'); if(is_array($currency_list)) { $currency_list = array_merge(Array($currency), $currency_list); } else { $currency_list = Array($currency); } $arr = array(); foreach($currency_list as $key=>$value) { $arr[$value->id] = $value->name; } $edit->ss->assign("EXCHANGE_RATE",get_select_options_with_id($arr, $focus->exchange_rate_id)); if(isset($fftemplateid) && $fftemplateid != '') $focus->template_id = $fftemplateid; $arr_template = $focus->getTemplateList(); $tt=""; $w=$GLOBALS['db']->query("select name,id,deleted,date_modified from ecmdocumenttemplates where deleted='0' or id='".$focus->template_id."'"); while($r=$GLOBALS['db']->fetchByAssoc($w)){ if($r['deleted']==1 && $_REQUEST['record']){ $tt.=''; } elseif($r['deleted']==0){ $tt.=''; } } $edit->ss->assign("DOCUMENT_TEMPLATES_OPTIONS", $tt); $rdoc=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select * from ecminsideorders where id='".$_REQUEST['record']."'")); $w=$GLOBALS['db']->query("select name,id from ecmstocks where deleted='0' order by name asc"); $rw=''; while($r=$GLOBALS['db']->fetchByAssoc($w)){ $rw.=''; while($r=$GLOBALS['db']->fetchByAssoc($w)){ $pw.='