bagfuloz Posted July 15, 2017 Share Posted July 15, 2017 Hello Guys, Facing issue with statement code under invoices. so issue is - I have two Different SAC code for hosting and domains and want to show them on invoices. Ex - For Domain - SAC: 12345 Ex - For Hosting - SAC: 45154 So I want show it on view invoice but if client raise order for domain, so it should show Domain Sac code else Hosting Sac code. I have added custom code - check the same. {if $invoiceitems.1.type = 'Domain'} <td class="total-row text-center">{$LANG.invoicessacdom}</td> {elseif $invoiceitems.1.type = 'Hosting'} <td class="total-row text-center">{$LANG.invoicessachost}</td> {/if} I have created two lang in lang/English.php file check the same - $_LANG['invoicessachost'] = "Hosting SAC: 998315 | Domain SSAC: N/A"; $_LANG['invoicessacdom'] = "SAC: N/A"; But its showing only one output, that is " invoicessacdom " can you tell me, how to get this done? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 15, 2017 Share Posted July 15, 2017 I would probably be inclined to modify the {foreach} loop and extend the description table row... {foreach from=$invoiceitems item=item} <tr> <td>{$item.description}{if $item.taxed eq "true"} *{/if}<br>{if $item.type eq 'Hosting'}{$LANG.invoicessachost}{elseif $item.type eq 'DomainRegister'}{$LANG.invoicessacdom}{/if}</td> <td class="text-center">{$item.amount}</td> </tr> {/foreach} also, note that your code isn't checking for domain transfers, addons etc - so you might need to expand the code to check for that. 0 Quote Link to comment Share on other sites More sharing options...
bagfuloz Posted July 20, 2017 Author Share Posted July 20, 2017 Thanks for the reply Brian, Its working. and how done same on pdf invoices ? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 20, 2017 Share Posted July 20, 2017 Thanks for the reply Brian, Its working. and how done same on pdf invoices ? it's going to be fairly similar, except you move the IF statement before the output... foreach ($invoiceitems as $item) { $tblhtml .= ' <tr bgcolor="#fff"> <td align="left">' . nl2br($item['description']) . '<br /></td> <td align="center">' . $item['amount'] . '</td> </tr>'; } to... foreach ($invoiceitems as $item) { if ($item['type'] == "Hosting") { $typeoutput = Lang::trans('invoicessachost').'<br />'; } elseif ($item['type'] == "DomainRegister") { $typeoutput = Lang::trans('invoicessacdom').'<br />'; } else { $typeoutput = ""; } $tblhtml .= ' <tr bgcolor="#fff"> <td align="left">' . nl2br($item['description']) . '<br />' . $typeoutput . '</td> <td align="center">' . $item['amount'] . '</td> </tr>'; } and when you want to add more conditions (transfers, addfunds, addons etc), you can just add more elseif conditions (before the final else) to the code. 0 Quote Link to comment Share on other sites More sharing options...
bagfuloz Posted July 20, 2017 Author Share Posted July 20, 2017 I have added code, at below on invoicepdf.tpl file but its seems not working , nothing showing. is there anything i need to done? Thanks 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 20, 2017 Share Posted July 20, 2017 sorry, perhaps I should have explained clearer... the first {foreach} block of code that I posted above already exists in invoicepdf.tpl - what you need to do is replace it with the second block of code... so don't add it separately after Notes, replace the foreach loop that is already there... do that and it should work. 0 Quote Link to comment Share on other sites More sharing options...
bagfuloz Posted July 22, 2017 Author Share Posted July 22, 2017 Thanks for your time and effort, all done, its working fine. 0 Quote Link to comment Share on other sites More sharing options...
bagfuloz Posted July 22, 2017 Author Share Posted July 22, 2017 Brain this is working fine, but when product is more than 2 so my custom SAC Code line hiding in table row . is there is a way to increase the size of table cell. check the screenshot. Thanks Buddy. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 22, 2017 Share Posted July 22, 2017 if you haven't modified/expanded the above code - as a temporary test, can you change.. <td align="left">' . nl2br($item['description']) . '<br />' . $typeoutput . '</td> to.. <td align="left">' . nl2br($item['description']) . '<br />' . $item['type'] . '</td> because I think they may not be considered 'Hosting' products in the database - I think they'll be 'server' and/or 'other' and if so, that's why the code isn't outputting anything. what the above code should do is output the type of the product as stored in the database, e.g DomainRegister, Hosting, Server, Other, AddFunds etc.. if so, then just add more elseif statements to check for these other product types. 0 Quote Link to comment Share on other sites More sharing options...
bagfuloz Posted July 22, 2017 Author Share Posted July 22, 2017 It will clear everything, Please take a look - When product is only 1 or 2 So - When product is more that 2 so - So this is a issue, when product is more that 2 so its hiding Sac code row. Thanks 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 22, 2017 Share Posted July 22, 2017 why is the output (SAC: 998315) outside of the foreach loop as per my code? if the output is going to be there then it will use the last value of the foreach loop - which in the first image is going to be "hosting"; and in the second, I assume those products aren't using the hosting type and therefore display nothing. so the problem is not the number of items in the invoice, it's the location of the output... or if you intend to only show one SAC code per invoice, then the code will need to change. I bet if you change your code to... if ($item['type'] == "Hosting") { $typeoutput = Lang::trans('invoicessachost').'<br />'; } elseif ($item['type'] == "DomainRegister") { $typeoutput = Lang::trans('invoicessacdom').'<br />'; } else { $typeoutput = "Brian"; } ... on the 2 product invoice, it will show the word "Brian" as the output. 0 Quote Link to comment Share on other sites More sharing options...
bagfuloz Posted July 24, 2017 Author Share Posted July 24, 2017 Sorry Brian, Sorry for my silly mistake, next time i will be-careful with this. Now i have clear idea, about it. Here product is Custom Dedicated hosting, so i try searching it in template variables by using {debug}, but not getting relevant search for custom dedicated or dedicated hosting variables. Please can you suggest some? Thanks 0 Quote Link to comment Share on other sites More sharing options...
bagfuloz Posted July 24, 2017 Author Share Posted July 24, 2017 (edited) As per my knowledge, I have added this code elseif ($customfields['type'] == "customfield") { $typeoutput = Lang::trans('invoicessachost').'<br />'; } but no luck. need right variable here. Edited July 24, 2017 by bagfuloz 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 24, 2017 Share Posted July 24, 2017 Sorry Brian, Sorry for my silly mistake, next time i will be-careful with this. Now i have clear idea, about it.Here product is Custom Dedicated hosting, so i try searching it in template variables by using {debug}, but not getting relevant search for custom dedicated or dedicated hosting variables. Please can you suggest some? if we're still talking about invoicepdf.tpl, using {debug} won't get you anywhere as it's not a Smarty template... there would be alternate ways of displaying the variables, but you won't need to as i've already told you the code to use.. https://forum.whmcs.com/showthread.php?131233-I-have-two-Different-SAC-code-for-hosting-and-domains-and-want-two-show-them-on-invoices&p=524941#post524941 you could replace the foreach loop with this... foreach ($invoiceitems as $item) { if ($item['type'] == "Hosting") { $typeoutput = Lang::trans('invoicessachost').'<br />'; } elseif ($item['type'] == "DomainRegister") { $typeoutput = Lang::trans('invoicessacdom').'<br />'; } else { $typeoutput = ""; } $tblhtml .= ' <tr bgcolor="#fff"> <td align="left">' . nl2br($item['description']) . '<br /><span style="background-color: #FFFF00">' . $item['type'] . '</span></td> <td align="center">' . $item['amount'] . '</td> </tr>'; } that will [highlight]highlight in yellow[/highlight] the product/service type text you need to use... then once you know the value for your dedicated hosting product, you can change the foreach code back to the previous version... e.g let's say we add DomainTransfer as an option... foreach ($invoiceitems as $item) { if ($item['type'] == "Hosting") { $typeoutput = Lang::trans('invoicessachost').'<br />'; } elseif ($item['type'] == "DomainRegister") { $typeoutput = Lang::trans('invoicessacdom').'<br />'; } elseif ($item['type'] == "DomainTransfer") { $typeoutput = Lang::trans('invoicessacdom').'<br />'; } else { $typeoutput = ""; } $tblhtml .= ' <tr bgcolor="#fff"> <td align="left">' . nl2br($item['description']) . '<br />' . $typeoutput . '</td> <td align="center">' . $item['amount'] . '</td> </tr>'; } 0 Quote Link to comment Share on other sites More sharing options...
bagfuloz Posted July 25, 2017 Author Share Posted July 25, 2017 (edited) Thanks for valuable reply Brian, Its also done, Here is the Final code - # Invoice Items $tblhtml = '<table width="100%" bgcolor="#ccc" cellspacing="1" cellpadding="2" border="0"> <tr height="30" bgcolor="#efefef" style="font-weight:bold;text-align:center;"> <td width="80%">' . Lang::trans('invoicesdescription') . '</td> <td width="20%">' . Lang::trans('quotelinetotal') . '</td> </tr>'; foreach ($invoiceitems as $item) { if ($item['type'] == "Hosting") { $typeoutput = Lang::trans('invoicessachost').'<br />'; } elseif ($item['type'] == "DomainRegister") { $typeoutput = Lang::trans('invoicessacdom').'<br />'; } elseif ($item['type'] == "DomainTransfer") { $typeoutput = Lang::trans('invoicessacdom').'<br />'; } elseif ($item['type'] == "DomainRenew") { $typeoutput = Lang::trans('invoicessacdom').'<br />'; } elseif ($item['type'] == "DomainRenewal") { $typeoutput = Lang::trans('invoicessacdom').'<br />'; } else { $typeoutput = "N/A"; } $tblhtml .= ' <tr bgcolor="#fff"> <td align="left">' . nl2br($item['description']) . '<br />' . $typeoutput . '</td> <td align="center">' . $item['amount'] . '</td> </tr>'; Thanks & Kind Regards Madan Malhotra Edited July 25, 2017 by bagfuloz 0 Quote Link to comment Share on other sites More sharing options...
bagfuloz Posted July 25, 2017 Author Share Posted July 25, 2017 Now, Other logic came in the picture, That We got one more SAC code for SMS services and SMS services Sac code is diffrent than Domain and Hosting Code, As we all know SMS Services, it's come under Other Product and service type. But in debug variable - $invoiceitems Origin: "Smarty object" Value Array (1) 0 => Array (7) id => 92170 type => "Hosting" relid => 8550 description => "Small" rawamount => "27.94" amount => "$27.94" taxed => true It's showing Type hosting. How to deal with this, How to define SMS service as other or any? For your information - Hosting, Emails, SSL, Spam Experts, Backup Services - SAC 998315 (Its done) Domain -SAC 998319 (Its done) SMS - SAC 440366 (Remaining) 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 25, 2017 Share Posted July 25, 2017 It's showing Type hosting. How to deal with this, How to define SMS service as other or any? oh 'eck... this is going to get messy! without resorting to hooks, I suspect you're going to have to filter on descriptions... SMS (and any hosting products that you don't want to be hosting) will need to be checked before hosting... foreach ($invoiceitems as $item) { if ($item['description'] == "Small" { $typeoutput = Lang::trans('invoicessacsms').'<br />'; } elseif ($item['type'] == "Hosting") { $typeoutput = Lang::trans('invoicessachost').'<br />'; } elseif ($item['type'] == "DomainRegister" or $item['type'] == "DomainRegister" or $item['type'] == "DomainRegister" or $item['type'] == "DomainRenewal") { $typeoutput = Lang::trans('invoicessacdom').'<br />'; } else { $typeoutput = "N/A"; } $tblhtml .= ' <tr bgcolor="#fff"> <td align="left">' . nl2br($item['description']) . '<br />' . $typeoutput . '</td> <td align="center">' . $item['amount'] . '</td> </tr>'; } 0 Quote Link to comment Share on other sites More sharing options...
bagfuloz Posted July 26, 2017 Author Share Posted July 26, 2017 As per requirement. Hope it will help others. if (($item['description'] == 'S1') || ($item['description'] == 'M1') || ($item['description'] == 'L1') || ($item['description'] == 'EL1')) { $typeoutput = Lang::trans('invoicessacsms').'<br />'; } elseif ($item['type'] == "Hosting") { $typeoutput = Lang::trans('invoicessachost').'<br />'; } elseif ($item['type'] == "DomainRegister") { $typeoutput = Lang::trans('invoicessacdom').'<br />'; } elseif ($item['type'] == "DomainTransfer") { $typeoutput = Lang::trans('invoicessacdom').'<br />'; } elseif ($item['type'] == "DomainRenew") { $typeoutput = Lang::trans('invoicessacdom').'<br />'; } elseif ($item['type'] == "DomainRenewal") { $typeoutput = Lang::trans('invoicessacdom').'<br />'; } else { $typeoutput = "N/A"; } $tblhtml .= ' <tr bgcolor="#fff"> <td align="left">' . nl2br($item['description']) . '<br />' . $typeoutput . '</td> <td align="center">' . $item['amount'] . '</td> </tr>'; Thanks for kind knowledge and support Brian 0 Quote Link to comment Share on other sites More sharing options...
bagfuloz Posted August 8, 2017 Author Share Posted August 8, 2017 oh 'eck... this is going to get messy! without resorting to hooks, I suspect you're going to have to filter on descriptions... SMS (and any hosting products that you don't want to be hosting) will need to be checked before hosting... foreach ($invoiceitems as $item) { if ($item['description'] == "Small" { $typeoutput = Lang::trans('invoicessacsms').'<br />'; } elseif ($item['type'] == "Hosting") { $typeoutput = Lang::trans('invoicessachost').'<br />'; } elseif ($item['type'] == "DomainRegister" or $item['type'] == "DomainRegister" or $item['type'] == "DomainRegister" or $item['type'] == "DomainRenewal") { $typeoutput = Lang::trans('invoicessacdom').'<br />'; } else { $typeoutput = "N/A"; } $tblhtml .= ' <tr bgcolor="#fff"> <td align="left">' . nl2br($item['description']) . '<br />' . $typeoutput . '</td> <td align="center">' . $item['amount'] . '</td> </tr>'; } Hello Brian, How this same should be done on viewinvoice.tpl file? correct me if i am wrong - {foreach from=$invoiceitems item=item} <tr> <td>{if $item.description eq 'S1'||'M1'||'L1'||'EL1'}{$LANG.invoicessacsms}{/if} 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 8, 2017 Share Posted August 8, 2017 that if line should be... {if $item.description eq 'S1' OR $item.description eq 'M1' OR $item.description eq 'L1' OR $item.description eq 'EL1'}{$LANG.invoicessacsms}{/if} 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.