60 lines
1.9 KiB
PHP
Executable File
60 lines
1.9 KiB
PHP
Executable File
<?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/EcmInventorys/EcmInventory.php');
|
|
require_once ('include/time.php');
|
|
|
|
$db = $GLOBALS['db'];
|
|
|
|
// $cq=$current_user->getPreference('confirm_quotes');
|
|
|
|
$new_number = false;
|
|
$duplicate = false;
|
|
$focus = new EcmInventory ();
|
|
|
|
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']);
|
|
}
|
|
else {
|
|
$new_number=true;
|
|
//dates
|
|
$focus->stock_id=$current_user->stock_id;
|
|
$focus->register_date = date("d.m.Y");
|
|
$OPT ['check_parent_id'] = false;
|
|
}
|
|
|
|
//get stocks
|
|
$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($row['id']==$focus->stock_id){$selected='selected';} else {
|
|
$selected='';}
|
|
$stock_body.='<option value="'.$row['id'].'" '.$selected.'>'.$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/EcmInventorys/views/EditView/view.edit.ecminventorys.php');
|
|
$edit = new ViewEditEcmInventorys ();
|
|
$edit->ss = new Sugar_Smarty ();
|
|
$edit->module = 'EcmInventorys';
|
|
$edit->bean = $focus;
|
|
$edit->tplFile = 'include/ECM/EcmViews/EditView/Tabs/EditView.tpl';
|
|
$edit->preDisplay ();
|
|
$edit->ss->assign ( "NEW_NUMBER", $new_number );
|
|
$edit->ss->assign("DUPLICATE", $duplicate);
|
|
$edit->ss->assign("STOCK", $stock);
|
|
echo $edit->display (); |