128 lines
4.7 KiB
PHP
128 lines
4.7 KiB
PHP
<?php
|
|
error_reporting(LC_ALL);
|
|
ini_set('display_errors',1);
|
|
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
|
|
|
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings, $current_user, $app_list_strings, $db, $timedate;
|
|
|
|
|
|
require_once('modules/EcmPrepaymentInvoices/EcmPrepaymentInvoice.php');
|
|
//require_once('modules/EcmPrepaymentInvoices/Forms.php');
|
|
require_once('include/json_config.php');
|
|
|
|
$json_config = new json_config();
|
|
$json = getJSONobj();
|
|
|
|
$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'];
|
|
|
|
require_once('include/MVC/View/SugarView.php');
|
|
require_once('modules/EcmPrepaymentInvoices/views/EditView/view.edit.php');
|
|
|
|
$focus = new EcmPrepaymentInvoice();
|
|
|
|
$cur = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select value from currency_nbp_archive where date<'".$focus->register_date."' and currency_id='".$focus->currency_id."' order by date desc limit 0,1;"));
|
|
|
|
if ($cur['value'])
|
|
$focus->currency_value_nbp = $cur['value'];
|
|
|
|
$edit = new EcmPrepaymentInvoicesViewEdit();
|
|
$edit->ss = new Sugar_Smarty();
|
|
$edit->module = 'EcmPrepaymentInvoices';
|
|
|
|
if($_REQUEST['ecmsale_id']){
|
|
$OPT['new_number'] = true;
|
|
$arr=array("parent_contact_name","currency_id","template_id","parent_id","parent_name","parent_address_street","parent_address_postalcode","parent_address_city","parent_address_country","total");
|
|
include_once("modules/EcmSales/EcmSale.php");
|
|
$sale=new EcmSale();
|
|
$sale->retrieve($_REQUEST['ecmsale_id']);
|
|
foreach($arr as $a)$focus->$a=$sale->$a;
|
|
$focus->description="Przedpłata do proformy za ".$sale->document_no;
|
|
$focus->register_date=$timedate->to_display_date(date("Y-m-d"));
|
|
$focus->payment_date=$timedate->to_display_date(date("Y-m-d"));
|
|
$focus->currency_value = $sale->currency_value;
|
|
// search for old prepaymentinvoices
|
|
$old_sum = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select sum(inv_value) as sum from ecmprepaymentinvoices where ecmsale_id='".$_REQUEST['ecmsale_id']."';"));
|
|
$focus->ecmsale_id = $_REQUEST['ecmsale_id'];
|
|
$focus->inv_value = ($sale->total_brutto - $old_sum['sum'])."";
|
|
$focus->ecmpaymentcondition_id = "ec14f1da-09c5-7b99-77ef-4e9fd3cfd67f";
|
|
$focus->ecmpaymentcondition_name = "Przedpłata";
|
|
$focus->parent_name_copy = $focus->parent_name;
|
|
$focus->to_vatid=$sale->parent_nip;
|
|
$focus->last_parent_id = $focus->parent_id;
|
|
$edit->ss->assign("isSale", true);
|
|
} else if ($_REQUEST['record']) {
|
|
$focus->retrieve($_REQUEST['record']);
|
|
$sale=new EcmSale();
|
|
$sale->retrieve($focus->ecmsale_id);
|
|
$focus->last_parent_id = $focus->parent_id;
|
|
$focus->parent_name_copy = $focus->parent_name;
|
|
}
|
|
|
|
$edit->bean = $focus;
|
|
|
|
$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'] && $focus->template_id){
|
|
$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);
|
|
|
|
$tt="";
|
|
$w=$GLOBALS[db]->query("select name,id,value from ecmvats where deleted='0' order by name");
|
|
while($r=$GLOBALS[db]->fetchByAssoc($w)){
|
|
$tt.='<option value="'.$r['id'].'"';
|
|
if($r['value']==23)$tt.=' selected';
|
|
$tt.='>'.$r['name'].'</option>';
|
|
}
|
|
$edit->ss->assign("ECMVATS_OPTIONS", $tt);
|
|
$edit->ss->assign("ecmsale_id", $focus->ecmsale_id);
|
|
$edit->ss->assign("ecmsale_name", $sale->document_no);
|
|
|
|
|
|
//$edit->tplFile = 'include/ECM/EcmViews/EditView/Tabs/EditView.tpl';
|
|
$edit->tplFile = 'include/EditView/EditView.tpl';
|
|
|
|
|
|
|
|
$scriptOpt = '<script language="javascript">
|
|
|
|
var OPT = '.str_replace('"','\"',$json->encode($OPT)).';
|
|
|
|
var MOD = '.str_replace('"','\"',$json->encode($mod_strings)).';
|
|
|
|
var N;
|
|
|
|
|
|
</script>';
|
|
echo $scriptOpt;
|
|
$edit->preDisplay();
|
|
|
|
|
|
echo $edit->display();
|
|
//echo '<div id="subpanels">';
|
|
//require_once('subpanels.php');
|
|
//echo '</div>';
|
|
?>
|