init
This commit is contained in:
432
modules/EcmStockDocIns/EditView.php
Executable file
432
modules/EcmStockDocIns/EditView.php
Executable file
@@ -0,0 +1,432 @@
|
||||
<?php
|
||||
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
|
||||
//require_once('modules/EcmGroupSales/HeaderMenu.php');
|
||||
|
||||
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings, $current_user, $app_list_strings;
|
||||
require_once('modules/EcmStockDocIns/EcmStockDocIn.php');
|
||||
require_once('modules/EcmStockDocIns/Forms.php');
|
||||
require_once ('include/time.php');
|
||||
require_once('include/json_config.php');
|
||||
|
||||
$json_config = new json_config();
|
||||
|
||||
$file = 'modules/EcmGroupSales/EcmGroupSale.php';
|
||||
if(file_exists($file)) {
|
||||
$cc = array();
|
||||
require_once($file);
|
||||
$cc = EcmGroupSale::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'];
|
||||
|
||||
if($cc['checkbox_demo'] == 1) {
|
||||
$query = "SELECT COUNT(id) as count FROM ecmstockdocins WHERE deleted='0'";
|
||||
$result = $GLOBALS['db']->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 EcmStockDocIn();
|
||||
|
||||
$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. <a href="index.php?module='.$_REQUEST['return_module'].'&action='.$_REQUEST['return_action'].'&record='.$_REQUEST['return_id'].'">return</a>';
|
||||
return;
|
||||
}
|
||||
$focus->format_all_fields();
|
||||
$focus->position_list = str_replace('"','\"',$focus->getPositionList());
|
||||
|
||||
//settings status
|
||||
if(!isset($focus->status) || $focus->status == '') $focus->status = 's10';
|
||||
else
|
||||
if($focus->status = 's40') $focus->status = 's10';
|
||||
}
|
||||
|
||||
|
||||
|
||||
} 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->kind='other';
|
||||
$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:'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'] = "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,"EcmStockDocIns",$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']['EcmVendors']['header_text'])) $d['texts']['EcmVendors']['header_text'] = $mod_strings['LBL_DEFAULT_ECMVENDOR_HEADER_TEXT'];
|
||||
if(!isset($d['texts']['EcmVendors']['footer_text'])) $d['texts']['EcmVendors']['footer_text'] = $mod_strings['LBL_DEFAULT_ECMVENDOR_FOOTER_TEXT'];
|
||||
if(!isset($d['texts']['EcmVendors']['ads_text'])) $d['texts']['EcmVendors']['ads_text'] = $mod_strings['LBL_DEFAULT_ECMVENDOR_ADS_TEXT'];
|
||||
|
||||
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");
|
||||
$nvats=$w->num_rows;
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$VAT[$r['id']]=array(
|
||||
"id"=>$r['id'],
|
||||
"name"=>$r['name'],
|
||||
"value"=>$r['value']
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$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 = '<script language="javascript">
|
||||
|
||||
var SHOW_PDF_IN_DIV ='.$show_pdf.';
|
||||
|
||||
var NOOFVATS ='.$nvats.';
|
||||
var UNIT ='.str_replace('"','\"',$json->encode($GLOBALS['app_list_strings']['ecmproducts_unit_dom'])).';
|
||||
|
||||
var VAT = '.str_replace('"','\"',$json->encode($VAT)).';
|
||||
|
||||
var OPT = '.str_replace('"','\"',$json->encode($OPT)).';
|
||||
|
||||
var MOD = '.str_replace('"','\"',$json->encode($mod_strings)).';
|
||||
|
||||
var N;
|
||||
|
||||
</script>';
|
||||
$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.='<script language="javascript">
|
||||
var UNIT_LANG='.str_replace('"','\"',$json->encode($UNIT_LANG)).';
|
||||
</script>';
|
||||
|
||||
echo $scriptOpt;
|
||||
|
||||
require_once('include/MVC/View/SugarView.php');
|
||||
|
||||
require_once('modules/EcmStockDocIns/views/EditView/view.edit.ecmstockdocins.php');
|
||||
|
||||
//for outside modules
|
||||
if(isset($_REQUEST['out_module']) && $_REQUEST['out_module'] != '' && isset($_REQUEST['out_id']) && $_REQUEST['out_id'] != '') {
|
||||
|
||||
$outModule = $_REQUEST['out_module'];
|
||||
$outId = $_REQUEST['out_id'];
|
||||
$OPT['fromOutside'] = true;
|
||||
$path = 'modules/'.$outModule.'/LoadEcmStockDocIns.php';
|
||||
if(file_exists($path)) {
|
||||
require_once($path);
|
||||
$_REQUEST['record'] = '';
|
||||
$outside_create = true;
|
||||
|
||||
$focus->out_module = $_REQUEST['out_module'];
|
||||
$focus->out_id = $_REQUEST['out_id'];
|
||||
}
|
||||
}
|
||||
|
||||
$edit = new ViewEditEcmStockDocIns();
|
||||
$edit->ss = new Sugar_Smarty();
|
||||
$edit->module = 'EcmStockDocIns';
|
||||
$edit->bean = $focus;
|
||||
|
||||
$edit->tplFile = 'include/ECM/EcmViews/EditView/Tabs/EditView.tpl';
|
||||
|
||||
$edit->ss->assign("OPT",$OPT);
|
||||
|
||||
$edit->preDisplay();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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."'");
|
||||
//echo $focus->template_id;
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
if($_REQUEST['record'] && $r['deleted']==1){
|
||||
$tt.='<option value="'.$r['id'].'"';
|
||||
if($r['id']==$focus->template_id)$tt.=' selected';
|
||||
$tt.='>'.$r['name'].' till '.$r['date_modified'].'</option>';
|
||||
}
|
||||
elseif($r['deleted']==0){
|
||||
$tt.='<option value="'.$r['id'].'"';
|
||||
if($r['id']==$focus->template_id)$tt.=' selected';
|
||||
$tt.='>'.$r['name'].'</option>';
|
||||
}
|
||||
}
|
||||
|
||||
$edit->ss->assign("DOCUMENT_TEMPLATES_OPTIONS", $tt);
|
||||
|
||||
$edit->ss->assign("POSITION_LIST",$focus->position_list);
|
||||
|
||||
if($cc['show_images_on_offers'] && $_REQUEST['record']=="")$c_sioo="checked";
|
||||
if($focus->show_images_on_offers==1 && $_REQUEST['record'])$c_sioo="checked";
|
||||
|
||||
$edit->ss->assign("CHECKBOX_SHOW_IMAGES_ON_OFFERS",$c_sioo);
|
||||
$edit->ss->assign("MFP",$focus->loadParserArray());
|
||||
|
||||
$stocks='<option value="">'.$GLOBALS['app_list_strings']['stock_select'].'</option>';
|
||||
$w=$GLOBALS['db']->query("select name,id from ecmstocks where deleted='0' order by name asc");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$stocks.='<option value="'.$r['id'].'"';
|
||||
if($r['id']==$focus->stock_id)$stocks.=' selected';
|
||||
$stocks.='>'.$r['name'].'</option>';
|
||||
}
|
||||
$edit->ss->assign("STOCK",$stocks);
|
||||
|
||||
//add mz 2012-04-02
|
||||
// kind on start
|
||||
if ($focus->kind=='other') {
|
||||
$edit->ss->assign("IMPORT", "display:none;");
|
||||
}
|
||||
if ($focus->kind=='import') {
|
||||
$edit->ss->assign("IMPORT", "display:block;");
|
||||
}
|
||||
|
||||
//import table
|
||||
$import_table='<table>
|
||||
<tr>
|
||||
<td class="dataLabel">'.$mod_strings['LBL_FOREIGN_TRANSPORT_VAL'].'</td>
|
||||
<td><input type="text" id="foreign_transport_val" name="foreign_transport_val" value="'.format_number($focus->foreign_transport_val).'"/></td>
|
||||
<td class="dataLabel">'.$mod_strings['LBL_FOREIGN_TRANSPORT_CUR_ID'].'</td>
|
||||
<td><select name="foreign_transport_cur_id" id="foreign_transport_cur_id"/>';
|
||||
foreach ($app_list_strings['currency_dom'] as $k=>$v){
|
||||
$import_table.='<option value="'.$k.'"';
|
||||
if ($k==$focus->foreign_transport_cur_id) $import_table.=' selected';
|
||||
$import_table.='>'.$v.'</option>';
|
||||
}
|
||||
$import_table.='</select></td>
|
||||
<td><input type="text" id="foreign_transport_cur_val" name="foreign_transport_cur_val" value="'.$focus->foreign_transport_cur_val.'"/></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="dataLabel">'.$mod_strings['LBL_COUNTRY_TRANSPORT_VAL'].'</td>
|
||||
<td><input type="text" id="country_transport_val" name="country_transport_val" value="'.format_number($focus->country_transport_val).'"/></td>
|
||||
<td class="dataLabel">'.$mod_strings['LBL_COUNTRY_TRANSPORT_CUR_ID'].'</td>
|
||||
<td><select name="country_transport_cur_id" id="country_transport_cur_id"/>';
|
||||
foreach ($app_list_strings['currency_dom'] as $k=>$v) {
|
||||
$import_table.='<option value="'.$k.'"';
|
||||
if ($k==$focus->country_transport_cur_id) $import_table.=' selected';
|
||||
$import_table.='>'.$v.'</option>';
|
||||
}
|
||||
$import_table.='</select></td>
|
||||
<td><input type="text" id="country_transport_cur_val" name="country_transport_cur_val" value="'.$focus->country_transport_cur_val.'"/></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="dataLabel">'.$mod_strings['LBL_ADDITION_COST_VAL'].'</td>
|
||||
<td><input type="text" id="addition_cost_val" name="addition_cost_val" value="'.format_number($focus->addition_cost_val).'"/></td>
|
||||
<td class="dataLabel">'.$mod_strings['LBL_ADDITION_COST_CUR_ID'].'</td>
|
||||
<td><select name="addition_cost_cur_id" id="addition_cost_cur_id"/>';
|
||||
foreach ($app_list_strings['currency_dom'] as $k=>$v) {
|
||||
$import_table.='<option value="'.$k.'"';
|
||||
if ($k==$focus->addition_cost_cur_id) $import_table.=' selected';
|
||||
$import_table.='>'.$v.'</option>';
|
||||
}
|
||||
$import_table.='</select></td>
|
||||
<td><input type="text" id="addition_cost_cur_val" name="addition_cost_cur_val" value="'.$focus->addition_cost_cur_val.'"/></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="dataLabel">'.$mod_strings['LBL_CURRENCY_ID'].'</td>
|
||||
<td><select name="currency_id" id="currency_id"/>';
|
||||
foreach ($app_list_strings['currency_dom'] as $k=>$v) {
|
||||
$import_table.='<option value="'.$k.'"';
|
||||
if ($k==$focus->currency_id) $import_table.=' selected';
|
||||
$import_table.='>'.$v.'</option>';
|
||||
}
|
||||
$import_table.='</select></td>
|
||||
<td class="dataLabel">'.$mod_strings['LBL_CURRENCY_VALUE'].'</td>
|
||||
<td><input type="text" id="currency_value" name="currency_value" value="'.format_number($focus->currency_value,4,4).'"/></td>
|
||||
<td class="dataLabel">'.$mod_strings['LBL_CURRENCY_SAD_VALUE'].'</td>
|
||||
<td><input type="text" id="currency_sad_value" name="currency_sad_value" value="'.format_number($focus->currency_sad_value,4,4).'"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
';
|
||||
$edit->ss->assign("IMPORT_TABLE",$import_table);
|
||||
//end mz
|
||||
/*
|
||||
|
||||
$_REQUEST['type'] = 'out';
|
||||
|
||||
$_REQUEST['parent_id'] = (isset($focus->id) && $focus->id != '')? $focus->id : '';
|
||||
|
||||
$_REQUEST['parent_type'] = 'EcmStockDocIns';
|
||||
|
||||
$_REQUEST['record'] = '';
|
||||
|
||||
$ob = '';
|
||||
|
||||
ob_start();
|
||||
|
||||
require_once('modules/EcmStockDocIns/Emails.php');
|
||||
|
||||
$ob = ob_get_contents();
|
||||
|
||||
ob_end_clean();
|
||||
|
||||
$mod_strings = return_module_language($current_language, 'EcmStockDocIns');
|
||||
|
||||
|
||||
|
||||
$edit->ss->assign("EMAILS",$ob);
|
||||
|
||||
*/
|
||||
|
||||
echo $edit->display();
|
||||
|
||||
if($_REQUEST['out_id']){
|
||||
echo '<script language="javascript">
|
||||
document.getElementById("parent_id").value="'.$source->parent_id.'";
|
||||
setTimeout(function(){
|
||||
document.getElementById("contact_id").value="'.$source->contact_id.'";
|
||||
document.getElementById("contact_name").value="'.$source->contact_name.'";
|
||||
},1500);
|
||||
</script>';
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
echo '<div id="subpanels">';
|
||||
|
||||
require_once('subpanels.php');
|
||||
|
||||
echo '</div>';
|
||||
|
||||
*/
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user