I have a problem with a website, I try to change some things on it, and for news page, I try to do in admin panel the option to upload image for news, like every time when you add a post in news page, to add 1 photo with.
And the guy who script this website have a strange script.
For admin panel the script its like that
case 'news':
echo "
<input type='text' class='ucp_input' id='news_title' placeholder='Titlu'><br>
<font style='font-size:11px;'>Te rog să foloseşti \n pentru linie nouă!</font><br>
<textarea class='acp_textarea' id='news_content' placeholder='Conţinut'></textarea><br>
Data expirării:<br>
<select id='news_expire_y' onchange='putMonths(\"news\")' class='acp_select'><option value='-1'>An</option></select> <select class='acp_select' id='news_expire_m' onchange='putDays(\"news\")'><option value='-1'>Luna</option></select> <select class='acp_select' id='news_expire_d'><option value='-1'>Zi</option></select><br>
<div id='acp_res' style='color:#f00;font-size:12px;'></div><br>
<img src='/img/ucp/submit.png' style='cursor:pointer;' onclick='addNews()'>";
break;
In functions I have this one
function add_news($title,$content,$y,$m,$d)
{
$title= addentities($title);
$content= addentities($content);
$y= intval(addentities($y));
$m= intval(addentities($m));
$d= intval(addentities($d));
$content=str_replace("\n","<br>",$content);
$st=0;
if($title==""){
$msg="Noua postare trebuie să aibă un titlu.";
}else if($content==""){
$msg="Noua postare trebuie să aibă un conţinut!";
}else if($y==-1 || $m==-1 || $d==-1){
$msg="Noua postare trebuie să aibă o data de expirare!";
}else if($y<intval(date("Y")) || ($y==intval(date("Y")) && $m<intval(date("m"))) || ($y==intval(date("Y")) && $m==intval(date("m")) && $d<intval(date("d")))){
$msg="Data expirarii nu poate fi în trecut.";
}else{
$expire=mktime(date("H"),date("i"),date("s"),$m,$d,$y);
$now=time();
$sql="insert into account.kwix_news_ro (`title`,`content`,`time`,`expire`) values ('$title','$content','$now','$expire')";
$rez=mysql_query($sql);
if($rez){
$msg="<font color='green'>Success!</font>";
$st=1;
}else{
$msg="Am întampinat o problemă.Te rugăm să încerci din nou.";
}
}
return json_encode(array("st"=>$st,"msg"=>$msg));
}
function get_news($ref,$_id=0)
{
$title="";
$content="";
$date="";
$id='';
$next=0;
$time=time();
if(intval($ref)==1){
$sql="select * from account.kwix_news_ro where `expire`>'$time' order by `time` desc";
}elseif(intval($ref)==2){
$_id= intval(addentities($_id));
$sql="select * from account.kwix_news_ro where `expire`>'$time' and `id`<".$_id." order by `time` desc";
}else{
$_id= intval(addentities($_id));
$sql="select * from account.kwix_news_ro where `expire`>'$time' and `id`>".$_id." order by `time` asc";
}
$rez=mysql_query($sql);
$row=mysql_num_rows($rez);
if($row){
$rand=mysql_fetch_array($rez);
$title=$rand['title'];
$time=$rand['time'];
$content=$rand['content'];
$date=date("d/m/Y H:i",$time);
$id=$rand['id'];
}
if($row>=2){
$next=1;
}
$prev=0;
if(intval($ref)==2){
$sql="select * from account.kwix_news_ro where `expire`>'$time' and `id`>=".$_id;
$rez=mysql_query($sql);
$row= mysql_num_rows($rez);
if($row) $prev=1;
}elseif(intval($ref)==3){
$time=time();
$sql="select * from account.kwix_news_ro where `expire`>'$time' and `id`>".($id);
$rez=mysql_query($sql);
$row= mysql_num_rows($rez);
if($row) $prev=1;
$next=1;
}
exit(json_encode(array("image"=>$image,"title"=>$title,"content"=>$content,"date"=>$date,'id'=>$id,"next"=>$next,"prev"=>$prev)));
}
And 1 file with name add_news.php
<?php
require '../inc/functions.php';
require '../inc/config.php';
if(isset($_GET['title']) && isset($_GET['content']) && isset($_GET['y']) && isset($_GET['m']) && isset($_GET['d']) && is_admin()){
$title=$_GET['title'];
$content=$_GET['content'];
$y=$_GET['y'];
$m=$_GET['m'];
$d=$_GET['d'];
echo add_news($title, $content, $y, $m, $d);
}
?>
And get_news.php
<?php
require '../inc/functions.php';
require '../inc/config.php';
if(isset($_GkET['first']))
{
get_news(1);
}else if(isset($_GET['id']) && isset($_GET['next'])){
get_news(2,$_GET['id']);
}else if(isset($_GET['id']) && isset($_GET['prev'])){
get_news(3,$_GET['id']);
}
?>
And I really do not understand its encryption mode and how can I make a correct script without changing the old script.
Related
I want to check if columns A B and C are filled with 'Yes' or 'yes' if so a action will follow.
I have this piece of code, and this is working for capitalized 'Yes'
if([1,2,3].indexOf(e.range.getColumn()) > -1) {
if (Col1 == "Yes" && Col2 == "Yes" && Col3 == "Yes") {Some action here}
But when I add || (OR) to it, the code fails.
if([1,2,3].indexOf(e.range.getColumn()) > -1) {
if ((Col1 == "Yes"||"yes") && (Col2 == "Yes"||"yes") && (Col3 == "Yes"||"yes") ) {Some action here}
Hoping for some help here ;)
If I understand the requirement the current approach may be cumbersome. A conditional count (case insensitive) of the three columns looking for "Yes" and then further action conditional on the result being 3 might be a little simpler.
Your OR statement is not right - you need to specify the variable that you are checking again. For instance:
if([1,2,3].indexOf(e.range.getColumn()) > -1) {
if ((Col1 == "Yes" || Col1 == "yes") && (Col2 == "Yes" || Col2 == "yes") && (Col3 == "Yes" || Col3 == "yes") ) {Some action here}
I am using our query tool to generate XML files for the topic GLTransactions of the XML API of Exact Online. The input for these files are XML Audit Files coming from Twinfield (XAF 3.1 format).
Since Exact Online has a mixed ledger and lots of constraints, it is not possible to directly load the bank entries. Instead, the bank transactions are posted into a separate General Ledger account of Exact Online with a separate journal as a first step when loading the XML Audit Files from Twinfield.
In the next step, the contents in Exact Online of the reserved General Ledger account are posted in the banking journal. Exact Online itself generates the other half as associated transaction lines for the banking general ledger.
The query used to generate the bank entries is:
create or replace table bank#inmemorystorage
as
select case
when substr(tle.description, 1, instr(tle.description, '/') - 1) = 'BNK'
then '20'
when substr(tle.description, 1, instr(tle.description, '/') - 1) = 'BNK2'
then '21'
else '??'
end
txn_journalcode
, txn.financialyear txn_financialyear
, txn.financialperiod txn_financialperiod
, txn.entrynumber txn_entrynumber
, txn.date txn_date
, tle.date tle_date
, tle.linenumber tle_linenumber
, substr(tle.description, instr(tle.description, '/') + 1, instr(tle.description, ':') - instr(tle.description, '/') - 1) tle_glaccountcode_target
, substr(tle.description, instr(tle.description, ':') + 2) tle_description
, trim(tle.accountcode) tle_accountcode
, tle.glaccountcode glaccountcode_source
, tle.amountdc tle_amountdc
, tle.vatcode tle_vatcode
, tle.yourref tle_yourref
from exactonlinerest..transactionlines tle
join exactonlinerest..transactions txn
on tle.entryid = txn.entryid
where tle.glaccountcode like '290%'
and substr(tle.description, instr(tle.description, '/') + 1, instr(tle.description, ':') - instr(tle.description, '/') - 1) not like '11%' /* Not a bank account. */
order
by tle.entrynumber
, tle.linenumber
select 'GLTransactions\99-Interim-empty.xml'
filename
, stg.fileprefix
|| chr(13)
|| '<GLTransactions>'
|| xml
|| chr(13)
|| '</GLTransactions>'
|| stg.filepostfix
filecontents
from ( select listagg
( chr(13)
|| '<GLTransaction entry="'
|| txn_entrynumber
|| '">'
|| chr(13)
|| '<Journal code="'
|| txn_journalcode
|| '" />'
|| chr(13)
|| '<Date>'
|| substr(xmlencode(txn_date), 1, 10)
|| '</Date>'
|| chr(13)
|| xml
|| chr(13)
|| '</GLTransaction>'
, ''
) xml
from ( select txn_date
, txn_journalcode
, txn_financialyear
, txn_financialperiod
, txn_entrynumber
, listagg
( chr(13)
|| '<GLTransactionLine type="40" linetype="0" line="'
|| tle_linenumber
|| '" offsetline="1" status="20">'
|| chr(13)
|| '<Date>'
|| substr(xmlencode(tle_date), 1, 10)
|| '</Date>'
|| chr(13)
|| '<FinYear number="'
|| txn_financialyear
|| '" />'
|| chr(13)
|| '<FinPeriod number="'
|| txn_financialperiod
|| '" />'
|| chr(13)
|| '<GLAccount code="'
|| case
when tle_glaccountcode_target = '1560'
then '2902' /* Separate interim GL account, Twinfield does not provide separated. */
else xmlencode(tle_glaccountcode_target)
end
|| '" />'
|| case
when tle_description is not null
then chr(13)
|| '<Description>'
|| xmlencode(tle_description)
|| '</Description>'
end
|| case
when tle_accountcode is not null
then chr(13)
|| '<Account code="'
|| xmlencode(tle_accountcode)
|| '" />'
end
|| chr(13)
|| '<Amount>'
|| '<Currency code="EUR" />'
|| '<Value>'
|| -1 * tle_amountdc
|| '</Value>'
|| case
when tle_glaccountcode_target like '4%'
then '<VAT code="GB" />' /* GB = No VAT. */
else ''
end
|| '</Amount>'
|| chr(13)
|| '</GLTransactionLine>'
, ''
)
xml
from bank#inmemorystorage
group
by txn_date
, txn_journalcode
, txn_financialyear
, txn_financialperiod
, txn_entrynumber
)
)
join settings#inmemorystorage stg
on 1=1
In the column tle_yourref in bank#inmemorystorage there is a comma-separated list of associated sales/purchase invoices.
When manually entering the General Ledger transaction on the bank journal, the contents of your ref are populated by the reconciliation window. However, when I export the XML file from Exact Online with transactions, the your ref is missing.
At this moment I seem uncapable to automatically reconcile through an XML or REST API of Exact Online these transactions in the bank journal.
As a workaround you can select each individual account in Reconciliation window (they practically all amount to EUR 0) and then choose Automatic reconciliation. But there are too many accounts to do it with each conversion from Twinfield to Exact Online.
Is there an alternative way to associate invoices with the bank transactions through an API (REST or XML) of Exact Online?
If there is a 1 on 1 relation between the invoice and the payment (so only 1 invoice and 1 payment) you can use <References><InvoiceNumber>put invoice entrynumber here</InvoiceNumber></References> in the bank entry to have it automatically reconciled.
Another possibility is to create an XML file with the topic MatchSets (see documentation) to have it matched afterwards.
Additionally, you can also say:
<References><EntryNumber>10000012</EntryNumber><InvoiceNumber>FAC0001</InvoiceNumber></References>
This always works when the relation is 1=1.
If you specify only the invoice number the matching often fails silently.
I have a uitextfield and i have got a search option using this uitextfield.When i enter the text it works well but when i clear the text i get "object returned empty description check" when i print it using po command in console. For checking this i have used the following code:
if(_nameTextField.text !=nil || _nameTextField.text.length !=0 || ![_nameTextField.text isEqual:#""]|| _nameTextField.text != NULL || ![_nameTextField.text isEqualToString:#""]){
}
But still it enters into the loop
use && instead of ||
if(_nameTextField.text !=nil && _nameTextField.text.length !=0 && ![_nameTextField.text isEqual:#""]&& _nameTextField.text != NULL && ![_nameTextField.text isEqualToString:#""]){
}
Please use this..it help you:
if (_nameTextField.text && _nameTextField.text.length!=0)
{
}
Use like this, it will work
if(_nameTextField.text !=nil && _nameTextField.text.length > 0 ){
//...
}
I have a List generated from Linq to Entities query. In which, I need to get a unique records based on BibId. I have tried changing the query but no help to get the unique records based on BibId.
Query
aa.NewBibContentsModel = (from x in db.BibContents
where (x.TagNo == "245" && x.NormValue == aa.CurrentTitle) || (x.TagNo == "020" && x.NormValue == aa.CurrentISBN) || (x.TagNo == "022" && x.NormValue == aa.CurrentISBN)
select new
{
BibId = x.BibId,
Title = (from a in db.BibContents where a.BibId == x.BibId && a.TagNo == "245" orderby a.Id ascending select a.NormValue),
//Tit = (from a in db.BibContents where a.BibId == line.BibId && a.TagNo == "245" && a.Sfld == "a" select a.NormValue).FirstOrDefault(),
Author = (from a in db.BibContents where a.BibId == x.BibId && splitted.Contains(a.TagNo) && a.NormValue != null select a.TagNo).FirstOrDefault(),
ISBN = (from a in db.BibContents where a.BibId == x.BibId && a.NormValue != null && (a.TagNo == "020" || a.TagNo == "022") orderby a.Id ascending select a.NormValue)
}).AsEnumerable().Select(x => new BibContentsModel
{
BibId = x.BibId,
Title = string.Join(" ", x.Title),
Author = string.Join(" ", (from a in db.BibContents where a.BibId == x.BibId && a.TagNo == x.Author orderby a.Id select a.NormValue)),
ISBN = string.Join(" ", x.ISBN)
}).ToList();
Any help to this problem will be appreciated.
Thanks
What you're trying to achieve is know as Distinct By. MoreLinq has a function for it. The syntax would look like:
(from x in db.BibContentsNo == "022")
... // your query
}).AsEnumerable()
.DistinctBy(x => x.BibId) // <= MoreLinq
What is does is group the records by BibId and take the first element of each group.
You can download MoreLinq as a NuGet package.
var postsidebar = from post in postrepository.GetAllPosts()
join pstmt in postrepository.GetAllPostMetas()
on post.int_PostId equals pstmt.int_PostId
where (post.int_PostTypeId == 4
&& post.int_PostStatusId == 2
&& post.int_OrganizationId == layoutrep.GetSidebarDetailById(SidebarDetailsId).int_OrganizationId)
&& (pstmt.vcr_MetaKey.Contains(filter) && pstmt.vcr_MetaValue.Contains("true")
&& (System.DateTime.Now >=
Convert.ToDateTime(pstmt.Post.PostMetas.FirstOrDefault(m =>
m.vcr_MetaKey == "Publish Date").vcr_MetaValue)))
select post;
how can i check for empty in this part in Date(it is giving error)
&& (System.DateTime.Now >= Convert.ToDateTime(pstmt.Post.PostMetas.FirstOrDefault(m =>
m.vcr_MetaKey == "Publish Date").vcr_MetaValue)))
You could try eliminated the possibility of an empty value first and then try your cast afterward.
&& pstmt.Post.PostMetas.FirstOrDefault(m =>
m.vcr_MetaKey == "Publish Date"
&& !string.IsNullOrEmpty(m.vcr_MetaValue))
&& (System.DateTime.Now >=
Convert.ToDateTime(pstmt.Post.PostMetas.FirstOrDefault(m =>
m.vcr_MetaKey == "Publish Date").vcr_MetaValue)))
Try this:
// declare the action for re-use
Func<PostMeta,bool> action = m => m.vcr_MetaKey == "Publish Date";
// then test for Any() before comparing anything
&& (pstmt.Post.PostMetas.Any(action) && System.DateTime.Now >= Convert.ToDateTime(pstmt.Post.PostMetas.First(action).vcr_MetaValue)))