149 lines
5.4 KiB
PHP
149 lines
5.4 KiB
PHP
<?php
|
|
if (! defined ( 'sugarEntry' ) || ! sugarEntry)
|
|
die ( 'NotAValidEntryPoint' );
|
|
|
|
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings, $current_user, $app_list_strings;
|
|
require_once ('modules/EcmInvoiceCosOuts/EcmInvoiceCosOut.php');
|
|
require_once ('include/time.php');
|
|
|
|
//add jquery
|
|
echo '<link rel="stylesheet" type="text/css" href="include/jQuery/jquery-table/jquery.appendGrid-1.3.1.css"/>';
|
|
echo '<link rel="stylesheet" type="text/css" href="include/jQuery/jquery-ui/themes/base/jquery-ui.css"/>';
|
|
echo '<script type="text/javascript"
|
|
src="include/jQuery/jquery-2.1.0.min.js"></script>';
|
|
echo '<script type="text/javascript"
|
|
src="include/jQuery/jquery-table/jquery.appendGrid-1.3.1.js"></script>';
|
|
echo '<script type="text/javascript"
|
|
src="include/jQuery/jquery-ui/ui/jquery-ui.js"></script>';
|
|
|
|
// $cq=$current_user->getPreference('confirm_quotes');
|
|
|
|
$new_number = false;
|
|
$is_correct=false;
|
|
$is_wz=false;
|
|
$is_sale=false;
|
|
$duplicate = false;
|
|
$focus = new EcmInvoiceCosOut ();
|
|
$db = $GLOBALS['db'];
|
|
|
|
if (isset ( $_REQUEST ['record'] ) && $_REQUEST['isDuplicate']=="false" ) {
|
|
$focus->retrieve ( $_REQUEST ['record'] );
|
|
if (isset ( $focus->id ) && $focus->id != '') {
|
|
$focus->format_all_fields ();
|
|
}
|
|
}
|
|
else if ($_REQUEST['isDuplicate']=="true") {
|
|
$new_number=true;
|
|
$duplicate=true;
|
|
//get data
|
|
$focus->retrieve($_REQUEST['return_id']);
|
|
$focus->register_date = date("d.m.Y");
|
|
$focus->sell_date = date("d.m.Y");
|
|
$focus->validtill_date = date("d.m.Y");
|
|
}
|
|
else if ($_REQUEST['isCorrect']=="true") {
|
|
$new_number=true;
|
|
$is_correct=true;
|
|
//get data
|
|
$focus->retrieve($_REQUEST['record']);
|
|
|
|
if (isset ( $focus->id ) && $focus->id != '') {
|
|
$focus->format_all_fields ();
|
|
}
|
|
$focus->register_date = date("d.m.Y");
|
|
$focus->sell_date = date("d.m.Y");
|
|
$focus->validtill_date = date("d.m.Y");
|
|
$focus->type='correct';
|
|
}else if ($_REQUEST['isWZ']=="true") {
|
|
$new_number=true;
|
|
$is_wz=true;
|
|
//get data
|
|
$wz= New EcmStockDocOut;
|
|
$wz->retrieve($_REQUEST['record']);
|
|
$wz_id=$_REQUEST['record'];
|
|
$so_id=$wz->so_id;
|
|
$wz_name=$wz->document_no;
|
|
// load from wz
|
|
$focus->parent_id=$wz->parent_id;
|
|
$focus->parent_name=$wz->parent_name;
|
|
$focus->order_no=$wz->order_no;
|
|
//dates
|
|
$focus->stock_id=$wz->stock_id;
|
|
$focus->stock_name=$wz->stock_name;
|
|
$focus->register_date = date("d.m.Y");
|
|
$focus->sell_date =$wz->register_date;
|
|
$focus->validtill_date = date("d.m.Y");
|
|
}else if ($_REQUEST['isSALE']=="true") {
|
|
|
|
$new_number=true;
|
|
$is_sale=true;
|
|
//get data
|
|
$wz= New EcmSale;
|
|
$wz->retrieve($_REQUEST['record']);
|
|
$so_id=$_REQUEST['record'];
|
|
$wz_name=$wz->document_no;
|
|
// load from wz
|
|
$focus->parent_id=$wz->parent_id;
|
|
$focus->parent_name=$wz->parent_name;
|
|
$focus->order_no=$wz->order_no;
|
|
$focus->ecmpaymentcondition_name=$wz->ecmpaymentcondition_name;
|
|
$focus->ecmpaymentcondition_id=$wz->ecmpaymentcondition_id;
|
|
//dates
|
|
$focus->stock_id=$wz->stock_id;
|
|
$focus->stock_name=$wz->stock_name;
|
|
$focus->register_date = date("d.m.Y");
|
|
$focus->sell_date =$wz->register_date;
|
|
$focus->validtill_date = date("d.m.Y");
|
|
} else {
|
|
$new_number=true;
|
|
//dates
|
|
$focus->stock_id=$current_user->stock_id;
|
|
|
|
$focus->register_date = date("d.m.Y");
|
|
$focus->sell_date = date("d.m.Y");
|
|
$focus->validtill_date = date("d.m.Y");
|
|
//for subpanels??
|
|
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;
|
|
}
|
|
}
|
|
|
|
$res = $db->query("SELECT id, name FROM ecmstocks WHERE deleted = '0' ORDER BY name");
|
|
$stock = '<select id="stock" name="stock"><option value=""></option>';
|
|
$stock_body = '';
|
|
while ($row = $db->fetchByAssoc($res)){
|
|
if($focus->stock_id!='' && $row['id']==$focus->stock_id){$s='selected';} else { $s='';}
|
|
$stock_body.='<option value="'.$row['id'].'" '.$s.'>'.$row['name'].'</option>';
|
|
}
|
|
$stock.=$stock_body.'</select><input id="stock_id" name="stock_id" type="hidden" value="'.$focus->stock_id.'"/>';
|
|
|
|
require_once ('include/MVC/View/SugarView.php');
|
|
require_once ('modules/EcmInvoiceCosOuts/views/EditView/view.edit.ecminvoicecosouts.php');
|
|
$edit = new ViewEditEcmInvoiceCosOuts ();
|
|
$edit->ss = new Sugar_Smarty ();
|
|
$edit->module = 'EcmInvoiceCosOuts';
|
|
$edit->bean = $focus;
|
|
$edit->tplFile = 'include/ECM/EcmViews/EditView/Tabs/EditView.tpl';
|
|
$edit->preDisplay ();
|
|
$edit->ss->assign ( "NEW_NUMBER", $new_number );
|
|
$edit->ss->assign ( "IS_CORRECT", $is_correct);
|
|
$edit->ss->assign ( "IS_WZ", $is_wz);
|
|
$edit->ss->assign ( "IS_SALE", $is_sale);
|
|
$edit->ss->assign ( "WZ_ID", $wz_id);
|
|
$edit->ss->assign ( "WZ_NAME", $wz_name);
|
|
$edit->ss->assign ( "SO_ID", $so_id);
|
|
$edit->ss->assign("DUPLICATE", $duplicate);
|
|
$edit->ss->assign("STOCK", $stock);
|
|
echo $edit->display ();
|
|
//loading view
|
|
echo '<link rel="stylesheet" type="text/css" href="modules/EcmInvoiceCosOuts/javascript/helper.css" media="screen" /><div class="loading_panel"></div>'; |