Delivery Customer Info

image

image

function mtel(tel){
if (tel.length==10) {tel =  tel.replace( /(\d{3})(\d{3})(\d{4})/,  '0($1) $2 $3' ) } 
else                {tel =  tel.replace( /(\d{3})(\d{4})/,  '0(212) $1 $2' )}
return tel}


function bakiye(tutar){
if (tutar>'0,00') {return "<br/><block 1 transparent left 70><i>Bakiye</i></block>:  <block 1 transparent left 320><color darkred><b>"+tutar+"</b></color> ₺ Debit</block>"}; 
if (tutar=='') {return ""}; 
if (tutar<'0,00') {return "<br/><block 1 transparent left 70><i>Bakiye</i></block>:  <block 1 transparent left 320><color green><b>"+tutar.replace('-','')+"</b></color> ₺ Credit</block>"}; 
if (tutar=='0,00') {return "<br/><block 1 transparent left 70><i>Bakiye</i></block>:  <block 1 transparent left 320>No Debit</block>"}; 

}

function id(ads){
var ids = sql.Query("SELECT TOP (1)  Tickets.Id FROM TicketEntities INNER JOIN Tickets ON TicketEntities.Ticket_Id = Tickets.Id WHERE EntityName in ('"+ads+"') AND Tickets.IsClosed = 1 ORDER BY TicketEntities.Ticket_Id DESC").First;
return ids}

function idson(ids){
var idson = sql.Query("SELECT TOP (1)  Tickets.Id FROM TicketEntities INNER JOIN Tickets ON TicketEntities.Ticket_Id = Tickets.Id WHERE EntityId = "+ids+" AND Tickets.IsClosed = 1 ORDER BY TicketEntities.Ticket_Id DESC").First;
return idson}

function siparis(ads){
var ids = sql.Query("SELECT TOP (1)  Tickets.Id FROM TicketEntities INNER JOIN Tickets ON TicketEntities.Ticket_Id = Tickets.Id WHERE EntityName in ('"+ads+"') AND Tickets.IsClosed = 1 ORDER BY TicketEntities.Ticket_Id DESC").First;
return sql.Query("SELECT CONCAT('<block 1 transparent left 330>','<block 1 transparent left 30>',CONCAT(FORMAT(Quantity,'#.##'),'x'),'</block><block 1 trasparent left 230>',CONCAT(MenuItemName,CASE WHEN PortionName = 'Normal' THEN NULL Else  CONCAT('.',PortionName) END),'</block><block 1 transparent right 70>',Format(Price,'C'),'</block></block>') FROM Orders WHERE TicketId = "+ids+" ORDER BY Price DESC").Join('<br/>')
}

function toplam(ads){
var ids = sql.Query("SELECT TOP (1)  Tickets.Id FROM TicketEntities INNER JOIN Tickets ON TicketEntities.Ticket_Id = Tickets.Id WHERE EntityName in ('"+ads+"') AND Tickets.IsClosed = 1 ORDER BY TicketEntities.Ticket_Id DESC").First;
return sql.Query("SELECT Format(TotalAmount,'C') FROM Tickets WHERE IsClosed = 1 AND Id = "+ids+"").First}

function count(ads){return sql.Query("SELECT COUNT(Tickets.Id) FROM TicketEntities INNER JOIN Tickets ON TicketEntities.Ticket_Id = Tickets.Id WHERE EntityName in ('"+ads+"') AND Tickets.IsClosed = 1").First; }

function grand(ads){
var ids = sql.Query("SELECT DISTINCT Tickets.Id FROM TicketEntities INNER JOIN Tickets ON TicketEntities.Ticket_Id = Tickets.Id WHERE EntityName in ('"+ads+"') AND Tickets.IsClosed = 1").Join();
return sql.Query("SELECT FORMAT(SUM(TotalAmount) , 'C') AS 'Currency Format'  FROM Tickets WHERE IsClosed = 1 AND Id IN ("+ids+")").First}

function gun(ads){
var ids = sql.Query("SELECT TOP (1)  Tickets.Id FROM TicketEntities INNER JOIN Tickets ON TicketEntities.Ticket_Id = Tickets.Id WHERE EntityName in ('"+ads+"') AND Tickets.IsClosed = 1 ORDER BY TicketEntities.Ticket_Id DESC").First;
var gun = sql.Query("SELECT DATEDIFF(day,Date,GETDATE()) FROM Tickets WHERE IsClosed = 1 AND Id = "+ids+"").First
if(gun==null){var gun = '0'} else {var gun = gun}
return gun}

function tarih(ads){
var ids = sql.Query("SELECT TOP (1)  Tickets.Id FROM TicketEntities INNER JOIN Tickets ON TicketEntities.Ticket_Id = Tickets.Id WHERE EntityName in ('"+ads+"') AND Tickets.IsClosed = 1 ORDER BY TicketEntities.Ticket_Id DESC").First;
return sql.Query("SELECT Date FROM Tickets WHERE IsClosed = 1 AND Id = "+ids+"").First}


function parite(ads){
var ids = sql.Query("SELECT DISTINCT Tickets.Id FROM TicketEntities INNER JOIN Tickets ON TicketEntities.Ticket_Id = Tickets.Id WHERE EntityName in ('"+ads+"') AND Tickets.IsClosed = 1").Join();
var g=sql.Query("SELECT SUM(TotalAmount) FROM Tickets WHERE IsClosed = 1 AND Id IN ("+ids+")").First.replace(',','.');
var c=sql.Query("SELECT COUNT(Tickets.Id) FROM TicketEntities INNER JOIN Tickets ON TicketEntities.Ticket_Id = Tickets.Id WHERE EntityName in ('"+ads+"') AND Tickets.IsClosed = 1").First;
var s= sql.Query("SELECT Format(CAST("+g+" AS FLOAT) / "+c+",'C') ").First;
return s

}

image

<block 1 transparent left 400>

<block 1 transparent left 70>Name</block>:  <block 1 transparent left 320><b>$1</b></block><br/>
<block 1 transparent left 70>Phone </block>:  <block 1 transparent left 320><b> {CALL:musteri.mtel('{ENTITY DATA:Phone}')}</b></block><br/>
<block 1 transparent left 70>Address</block>:  <block 1 transparent left 320 wrap><b> {ENTITY DATA:Address}</b></block><br/>
<block 1 transparent left 70>PostCode</block>:  <block 1 transparent left 320><b> {ENTITY DATA:PostCode}</b></block><br/>
<block 1 transparent left 70>Street</block>:  <block 1 transparent left 320><b> {ENTITY DATA:Street}</b></block><br/>
<block 1 transparent left 70>Town</block>:  <block 1 transparent left 320><b> {ENTITY DATA:Town}</b></block><br/>
<block 1 transparent left 70>County</block>:  <block 1 transparent left 320><b> {ENTITY DATA:County}</b></block><br/>
<block 1 transparent left 70>No</block>:  <block 1 transparent left 320><b> {ENTITY DATA:No}</b></block><br/>
<block 1 transparent left 70>Distance</block>:  <block 1 transparent left 320><b> {ENTITY DATA:Distance}</b> km</block>
{CALL:musteri.bakiye('{ENTITY BALANCE}')}
</block>

<br/>________________________________________________________________________
<br/>
<block 1 transparent left 360>
<block 1 transparent center 340><b>Customer INFO</b></block><br/>
<block 1 transparent left 150>Ticket Count</block>:  <block 1 transparent right 190><b>{CALL:musteri.count('$1')}</b> Qty</block><br/>
<block 1 transparent left 150>Grand Total</block>: <block 1 transparent right 190><b>{CALL:musteri.grand('$1')}</b></block><br/>
<block 1 transparent left 150>Average</block>:  <block 1 transparent right 190><b>{CALL:musteri.parite('$1')}</b></block><br/>
<block 1 transparent left 150>Last Order Date</block>:  <block 1 transparent right 190><b>{CALL:musteri.gun('$1')}</b> day <br/><b>{CALL:musteri.tarih('$1')}</b></block><br/>
</block>
<br/>________________________________________________________________________
<br/>
<block 1 transparent left 350>
<block 1 transparent left 100><b> Last Order </b></block>
<block 1 transparent center 130>#( {CALL:musteri.id('$1')} )</block>
<block 1 transparent right 100><b> {CALL:musteri.toplam('$1')}</b></block><br/>
<size 15>{CALL:musteri.siparis('$1')}</size>
</block>


5 Likes

<block 1 #FFFFDFA3 left 400>

<block 1 transparent left 70>Name</block>:  <block 1 transparent left 320><b>$1</b></block><br/>
<block 1 transparent left 70>Phone </block>:  <block 1 transparent left 320><b> {CALL:musteri.mtel('{ENTITY DATA:Phone}')}</b></block><br/>
<block 1 transparent left 70>Address</block>:  <block 1 transparent left 320 wrap><b> {ENTITY DATA:Address}</b></block><br/>
<block 1 transparent left 70>PostCode</block>:  <block 1 transparent left 320><b> {ENTITY DATA:PostCode}</b></block><br/>
<block 1 transparent left 70>Street</block>:  <block 1 transparent left 320><b> {ENTITY DATA:Street}</b></block><br/>
<block 1 transparent left 70>Town</block>:  <block 1 transparent left 320><b> {ENTITY DATA:Town}</b></block><br/>
<block 1 transparent left 70>County</block>:  <block 1 transparent left 320><b> {ENTITY DATA:County}</b></block><br/>
<block 1 transparent left 70>No</block>:  <block 1 transparent left 320><b> {ENTITY DATA:No}</b></block><br/>
<block 1 transparent left 70>Distance</block>:  <block 1 transparent left 320><b> {ENTITY DATA:Distance}</b> km</block>
{CALL:musteri.bakiye('{ENTITY BALANCE}')}
</block>


<block 1 lightgreen left 400>
<block 1 transparent center 340><b>Customer INFO</b></block><br/>
<block 1 transparent left 150>Ticket Count</block>:  <block 1 transparent right 190><b>{CALL:musteri.count('$1')}</b> Qty</block><br/>
<block 1 transparent left 150>Grand Total</block>: <block 1 transparent right 190><b>{CALL:musteri.grand('$1')}</b></block><br/>
<block 1 transparent left 150>Average</block>:  <block 1 transparent right 190><b>{CALL:musteri.parite('$1')}</b></block><br/>
<block 1 transparent left 150>Last Order Date</block>:  <block 1 transparent right 190><b>{CALL:musteri.gun('$1')}</b> gün <br/><b>{CALL:musteri.tarih('$1')}</b></block><br/>
</block>

<block 1 skyblue left 400>
<block 1 transparent left 100><b> Last Order </b></block>
<block 1 transparent center 130>#( {CALL:musteri.id('$1')} )</block>
<block 1 transparent right 100><b> {CALL:musteri.toplam('$1')}</b></block><br/>
<size 15>{CALL:musteri.siparis('$1')}</size>
</block>

1 Like

<block 2 black left 1130>
<block 2 black center 406>
<block 1 #FFFFDFA3 left 400>
<block 2 transparent left 70>Name</block>:  <block 1 transparent left 320><b>$1</b></block><br/>
<block 1 transparent left 70>Phone </block>:  <block 1 transparent left 320><b> {CALL:musteri.mtel('{ENTITY DATA:Phone}')}</b></block><br/>
<block 1 transparent left 70>Address</block>:  <block 1 transparent left 320 wrap><b> {ENTITY DATA:Address}</b></block><br/>
{CALL:musteri.bakiye('{ENTITY BALANCE}')}
</block>
</block>
<block 2 black center 366>
<block 2 lightgreen left 360>
<block 1 transparent center 350><b>Customer INFO</b></block><br/>
<block 1 transparent left 150>Ticket Count</block>:  <block 1 transparent right 190><b>{CALL:musteri.count('$1')}</b> Qty</block><br/>
<block 1 transparent left 150>Grand Total</block>: <block 1 transparent right 190><b>{CALL:musteri.grand('$1')}</b></block><br/>
<block 1 transparent left 150>Average</block>:  <block 1 transparent right 190><b>{CALL:musteri.parite('$1')}</b></block><br/>
<block 1 transparent left 150>Last Order Date</block>:  <block 1 transparent right 190><b>{CALL:musteri.gun('$1')}</b> gün <br/><b>{CALL:musteri.tarih('$1')}</b></block>
</block>
</block>
<block 2 black center 356>
<block 2 skyblue left 350>
<block 1 transparent left 100><b> Last Order </b></block>
<block 1 transparent center 130>#( {CALL:musteri.id('$1')} )</block>
<block 1 transparent right 100><b> {CALL:musteri.toplam('$1')}</b></block><br/>
<size 15>{CALL:musteri.siparis('$1')}</size>
</block>
</block>
</block>
2 Likes