183 lines
8.3 KiB
PHP
183 lines
8.3 KiB
PHP
<?php
|
|
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
|
|
|
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings, $current_user;
|
|
|
|
require_once('modules/EcmTransactions/EcmTransaction.php');
|
|
require_once('modules/EcmTransactions/Forms.php');
|
|
require_once ('include/time.php');
|
|
require_once('include/json_config.php');
|
|
|
|
$json_config = new json_config();
|
|
$focus = new EcmTransaction();
|
|
|
|
if(isset($_REQUEST['record']) && $_REQUEST['record'] != '') {
|
|
$focus->retrieve($_REQUEST['record']);
|
|
$focus->format_all_fields();
|
|
}
|
|
if (isset($_REQUEST['parent_id']) && $_REQUEST['parent_id']!='') {
|
|
$a = new Account();
|
|
$a->retrieve($_REQUEST['parent_id']);
|
|
$focus->id=create_guid();
|
|
$focus->parent_id = $a->id;
|
|
$focus->parent_name = $a->name;
|
|
$focus->payment_date = date('d.m.Y');
|
|
global $current_user;
|
|
$focus->assigned_user_id = $current_user->id;
|
|
$focus->assigned_user_name = $current_user->full_name;
|
|
$focus->format_all_fields();
|
|
unset($a);
|
|
}
|
|
|
|
require_once('include/MVC/View/SugarView.php');
|
|
require_once('modules/EcmTransactions/view/EditView/view.edit.my.php');
|
|
|
|
$edit = new ViewEditMy();
|
|
$edit->ss = new Sugar_Smarty();
|
|
$edit->module = 'EcmTransactions';
|
|
$edit->bean = $focus;
|
|
$edit->tplFile = 'include/EditView/EditViewClassic.tpl';
|
|
/*
|
|
$w=mysql_query("select document_no,register_date,id,total from ecminvoiceouts where deleted='0'");
|
|
$i=0;
|
|
$inv='<table cellspacing="0" cellpadding="0" border="0" width="100%">';
|
|
while($r=mysql_fetch_array($w)){
|
|
//if($i%3==0)
|
|
$inv.='<tr>';
|
|
$inv.='<td><input type="checkbox" name="inv[]" value="'.$r['id'].'"';
|
|
$ww=mysql_query("select id from ecmtransactions_ecminvoiceouts where ecminvoiceout_id='".$r['id']."' and ecmtransaction_id='".$focus->id."' and deleted='0'");
|
|
if(mysql_num_rows($ww)>0)$inv.=" checked";
|
|
$inv.='> <a href="index.php?module=EcmInvoiceOuts&action=DetailView&record='.$r['id'].'">'.$r['document_no'].'</a> - '.$GLOBALS['timedate']->to_display_date($r['register_date']).' - '.number_format($r['total'],2,",",".").'</td>';
|
|
//if($i%3==2)
|
|
$inv.='</tr>';
|
|
$i++;
|
|
}
|
|
$inv.='</table>';
|
|
$inv.='
|
|
<div id="invoices">
|
|
</div>*/
|
|
/*$inv.='
|
|
|
|
<script language="javascript">
|
|
function openPopupSelect(i){
|
|
return open_popup("EcmInvoiceOuts", 600, 400, "", true, false, {"call_back_function":"set_return","form_name":"EditView","field_to_name_array":{"id":"inv_id"+i,"document_no":"inv_name"+i}}, "single", true);
|
|
}
|
|
function addRow(i){
|
|
document.getElementById(\'inv\'+i).style.display=\'block\';
|
|
document.getElementById(\'inv_no\').value=parseInt(i)+1;
|
|
|
|
}
|
|
</script>';
|
|
$w=mysql_query("select ecminvoiceout_id as iid,ecmtransaction_id as pid from ecmtransactions_ecminvoiceouts where deleted='0' and ecmtransaction_id='".$focus->id."'");
|
|
echo mysql_error();
|
|
$inv.='<input type="hidden" id="inv_no" value="'.mysql_num_rows($w).'"/>
|
|
<input type="button" onclick="addRow(document.getElementById(\'inv_no\').value);" class="button" value="Add"/>
|
|
<div id="invoices">';
|
|
$i=0;
|
|
while($r=mysql_fetch_array($w)){
|
|
$rr=mysql_fetch_array(mysql_query("select document_no from ecminvoiceouts where id='".$r['iid']."' and deleted='0'"));
|
|
if($rr['document_no']){
|
|
$inv.='<div id="inv'.$i.'"><input class="sqsEnabled" name="inv_name'.$i.'" tabindex="" id="inv_name'.$i.'" size="" value="'.$rr['document_no'].'" title="" type="text"><input name="inv_id'.$i.'" id="inv_id'.$i.'" value="'.$r['iid'].'" type="hidden"> <input onclick="openPopupSelect('.$i.');" class="button" type="button" id="select'.$i.'" value="Select" /> <input onclick=document.getElementById("inv'.$i.'").innerHTML=""; class="button" type="button" id="del'.$i.'" value="Delete" /></div>
|
|
<script>
|
|
if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}sqs_objects[\'inv_name'.$i.'\']={"method":"query","modules":["EcmInvoiceOuts"],"group":"or","field_list":["document_no","id"],"populate_list":["inv_name'.$i.'","inv_id'.$i.'"],"conditions":[{"name":"document_no","op":"like_custom","end":"%","value":""}],"required_list":["inv_id'.$i.'"],"order":"document_no","limit":"30","no_match_text":"No Match"};
|
|
</script>';
|
|
$i++;
|
|
}
|
|
}
|
|
$inv.='</div>';
|
|
for($l=$i;$l<100;$l++){
|
|
$inv.='<div id="inv'.$l.'" style="display:none;"><input class="sqsEnabled" name="inv_name'.$l.'" tabindex="" id="inv_name'.$l.'" size="" value="" title="" type="text"><input name="inv_id'.$l.'" id="inv_id'.$l.'" value="" type="hidden"> <input onclick="openPopupSelect('.$l.');" class="button" type="button" id="select'.$l.'" value="Select" /> <input onclick=document.getElementById("inv'.$l.'").innerHTML=""; class="button" type="button" id="del'.$l.'" value="Delete" /></div><script>if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}sqs_objects[\'inv_name'.$l.'\']={"method":"query","modules":["EcmInvoiceOuts"],"group":"or","field_list":["document_no","id"],"populate_list":["inv_name'.$l.'","inv_id'.$i.'"],"conditions":[{"name":"document_no","op":"like_custom","end":"%","value":""}],"required_list":["inv_id'.$l.'"],"order":"document_no","limit":"30","no_match_text":"No Match"};</script>';
|
|
}*/
|
|
echo $focus->parent_name;
|
|
if($_REQUEST['type']==1){ $selected='selected'; $focus->link=1;
|
|
$a='<option label="Ma" value="1" '.$selected.'>Ma</option></select>';
|
|
$typess='<select name="type" id="type" title="" tabindex="105" '.$disabled.'>'.$a.'</option>';}
|
|
if($_REQUEST['type']==0) { $selected1='selected'; $focus->link=1;
|
|
$a='<option label="Winien" value="0" '.$selected1.'>';
|
|
$typess='<select name="type" id="type" title="" tabindex="105" '.$disabled.'>'.$a.'Winien</option>';}
|
|
if(!isset($_REQUEST['type'])){
|
|
if($focus->type!=null){
|
|
if($focus->type==0){ $typess='<select name="type" id="type" title="" tabindex="105" '.$disabled.'><option label="Winien" value="0" selected>Winien</option></select>';
|
|
} else {
|
|
$typess='<select name="type" id="type" title="" tabindex="105" '.$disabled.'><option label="Ma" value="1" selected>Ma</option></select>'; }
|
|
} else {
|
|
$focus->link=0; $typess='<select name="type" id="type" title="" tabindex="105" '.$disabled.'><option label="Winien" value="0" '.$selected1.'>Winien</option><option label="Ma" value="1" '.$selected.'>Ma</option></select>';}
|
|
}
|
|
if(isset($focus->id)){
|
|
$canc='<input type="button" id="canc" onclick="location.href=';
|
|
$canc.="'index.php?module=EcmTransactions&action=DetailView&record=";
|
|
$canc.=$focus->id;
|
|
$canc.="'";
|
|
$canc.='" value="Anuluj">';
|
|
} else {
|
|
$canc='<input type="button" id="canc" onclick="location.href=';
|
|
$canc.="'index.php?module=EcmTransactions";
|
|
$canc.="'";
|
|
$canc.='" value="Anuluj">';
|
|
}
|
|
|
|
|
|
$edit->ss->assign("GUZIK",$canc);
|
|
echo '<script type="text/javascript" src="jscalendar/mintAjax.js"></script>';
|
|
$edit->ss->assign("JS","<script>function getNBPCurrencyExchange() {
|
|
var c_id = document.getElementById('currency_id').value;
|
|
var date = document.getElementById('payment_date').value;
|
|
|
|
url='index.php?module=Currencies&action=getNBPCurrencyExchange&c_id='+c_id+'&date='+date+'&to_pdf=1';
|
|
var req=mint.Request();
|
|
req.OnSuccess = function() {
|
|
if (this.responseText == -1) return;
|
|
if (this.responseText!=''){
|
|
this.responseText = this.responseText.replace('.', ',');
|
|
document.getElementById('currency_value').value = (this.responseText);
|
|
}
|
|
}
|
|
req.Send(url);
|
|
}
|
|
setInterval('getNBPCurrencyExchange();',1000);</script>");
|
|
$edit->ss->assign("TYPESS",$typess);
|
|
$edit->ss->assign("INVOICES",$inv);
|
|
$edit->preDisplay();
|
|
echo $edit->display();
|
|
if(isset($focus->id) || isset($_REQUEST['parent_id'])){
|
|
echo "<script>";
|
|
|
|
if($_REQUEST['type']==0 || $focus->type==0){
|
|
|
|
echo " var sel = document.getElementById('type2');
|
|
sel.options[3].selected=true;
|
|
for (var i=0;i<sel.length;i++)
|
|
{
|
|
if(sel.options[i].value[0]!='W'){
|
|
sel.options[i].style.display='none';
|
|
} else {
|
|
sel.options[i].style.display='block';
|
|
}
|
|
if(sel.options[i].value=='".$focus->type2."'){
|
|
sel.options[i].selected=true;
|
|
}
|
|
}";
|
|
}
|
|
if($_REQUEST['type']==1 || $focus->type==1){
|
|
echo " var sel = document.getElementById('type2');
|
|
|
|
for (var i=0;i<sel.length;i++)
|
|
{
|
|
if(sel.options[i].value[0]!='M'){
|
|
sel.options[i].style.display='none';
|
|
} else {
|
|
sel.options[i].style.display='block';
|
|
sel.options[i].selected=true;
|
|
}
|
|
if(sel.options[i].value=='".$focus->type2."'){
|
|
sel.options[i].selected=true;
|
|
}
|
|
}";
|
|
}
|
|
|
|
echo "document.getElementById('parent_name').size='54';
|
|
document.getElementById('parent_name').readOnly=true;
|
|
document.getElementById('btn_parent_name').style.display='none';
|
|
document.getElementById('btn_clr_parent_name').style.display='none';</script>";
|
|
}
|
|
?>
|