• Deepu161
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 10
    Replies
public class generatePasswordController {
    public Boolean alert{get;set;}
    public String msg{get;set;}
    public String redirecturl{get;set;}
    private final Employee__c o;
    Public Id EmployeeId {get;set;}
    public generatePasswordController (ApexPages.StandardController stdController) {
        alert=false;
        this.o = (Employee__c)stdController.getRecord();
        EmployeeId = ApexPages.currentPage().getParameters().get('Id');
    }
    public PageReference CreateAndSendEmail() {
        String ats_URL = Label.ATS_URL;

        list<Employee__c> EmpDetails = [SELECT Id, Name, Site_Username__c, Site_Password__c,Email_1st__c FROM Employee__c WHERE id = : EmployeeId];
        if(EmpDetails[0].Email_1st__c == Null || EmpDetails[0].Email_1st__c == ''){
            alert = true;
            redirecturl = '/'+EmpDetails[0].Id;
            return null;
        }
        else{
            //Generating random passwords
            
            TimeCardEntrySiteURL__c mc = TimeCardEntrySiteURL__c.getInstance('TimeCardEntry');
            string urlcode = mc.URLforTimeCardEntry__c;
            
            Integer len = 10;
            Blob blobKey = crypto.generateAesKey(128);
            String key = EncodingUtil.convertToHex(blobKey);
            String pwd = key.substring(0,len);
            System.debug('************ '+pwd);
            
            for(employee__c E:EmpDetails){
                E.Site_Username__c = E.Email_1st__c + '.ats';
                E.Site_Password__c = pwd;
            }
            
            update Empdetails;
            OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address = 'it@accesstechnologys.com'];
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            String messageBody;
            String[] toAddresses = new String[] {EmpDetails[0].Email_1st__c};
            mail.setToAddresses( toAddresses ); 
            mail.setOrgWideEmailAddressId(owea.get(0).Id);
            mail.setReplyTo('donotreply@salesforce.com'); 
            //mail.setSenderDisplayName('IT Administrator'); 
            mail.setSubject('Access Technology Solutions Time Card Portal : Username And Password' ); 
            mail.setBccSender(false); 
            
            mail.setUseSignature(false);
            //messageBody = '<html><body>Dear ' +EmpDetails[0].Name  + ',<br></br><br></br> Below is the information for logging into the Time Card Portal <br></br><br></br> UserName : '+EmpDetails[0].site_username__c +' <br><br> Password :'+EmpDetails[0].site_password__c +' <br><br> You can Update password related with your account by clicking on this link below:<br><br>'+ UrlCode +'/UpdatePswdPage?Employeeid='+ EmpDetails[0].Id+'&EmployeeName='+EmpDetails[0].site_username__c+' <br></br><br></br>Regards,<br></br>Access Technology Solutions - IT Support<br></br>Office: (800) 637-9569 - 801 | Fax : (800) 637-9569<br></br>www.accesstechnologys.com</body></html>'; 
            messageBody = '<html><body>Dear ' +EmpDetails[0].Name  + ',<br></br><br></br> Below is the information for logging into the Time Card Portal <br></br><br></br> UserName : '+EmpDetails[0].site_username__c +' <br><br> Password :'+EmpDetails[0].site_password__c +' <br><br> You can Update password related with your account by clicking on this link below:<br><br>'+ ats_URL+'?update=updatepassword&Employeeid='+ EmpDetails[0].Id+'&username='+EmpDetails[0].site_username__c+' <br></br><br></br>Regards,<br></br>Access Technology Solutions - IT Support<br></br>Office: (800) 637-9569 - 801 | Fax : (800) 637-9569<br></br>www.accesstechnologys.com</body></html>';
            mail.setHtmlBody(messageBody);
            mail.setPlainTextBody(messageBody);
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); 
            
            PageReference employeePage = new PageReference('/' + EmployeeId);
            employeePage.setRedirect(true);
            return employeePage;
        }
   } 
}

 

======================test class======================
@isTest
public class showallTimeCatdsCtrl2_Test{
public static testMethod void showtimcardMethod(){
        Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];
        User u = new User(  Alias = 'standt', Email='standarduser@testorg.com', EmailEncodingKey='UTF-8',
                            LastName='Testing123', LanguageLocaleKey='en_US', LocaleSidKey='en_US', ProfileId = p.Id,
                            TimeZoneSidKey='America/Los_Angeles', UserName='standarduser123@testorg.com');

        Account acc = new Account();
        acc.Name = 'test';
        insert acc;
        System.assertEquals('test',acc.Name);

        Contact cont = new Contact();
        cont.FirstName='Test';
        cont.LastName='Test';
        cont.Accountid= acc.id;
        insert cont;

        Employee__c emp=new Employee__c();
        emp.Name='pradeep';
        emp.Active__c=true;
        emp.Subcontractor_Account__c=acc.id;
        emp.Reports_to__c=u.id;
        emp.Portal_Contact__c=cont.id;
        emp.Phone__c='984466';
        insert emp;
        System.assertEquals('pradeep',emp.Name);

        Project__c prj=new Project__c();
        prj.Name='salesforceproject';
        prj.Account__c=acc.id;
        prj.Account_Manager__c=emp.id;
        prj.Client__c=cont.id;
        prj.Account_Manager__c=emp.id;
        insert prj;
        System.assertEquals('salesforceproject',prj.Name);

        Employee__c emp2=new Employee__c();
        emp2.Name='ramesh';
        emp2.Active__c=true;
        emp2.Subcontractor_Account__c=acc.id;
        emp2.Reports_to__c=u.id;
        emp2.Portal_Contact__c=cont.id;
        emp2.Phone__c='9846';
        insert emp2;
        System.assertEquals('ramesh',emp2.Name);

        prj.Resource1__c = emp2.Id;
        prj.Pay1__c = 100;
        update prj;

        Employee_Rate_Card__c empRateCard = new Employee_Rate_Card__c();
        empRateCard.Resource__c = emp2.Id;
        empRateCard.Project__c = prj.Id;
        empRateCard.From__c = Date.today().addDays(-7);
        empRateCard.To__c = Date.today().addDays(7);
        empRateCard.Rate__c = 50;
        insert empRateCard;

        Invoice__c inv=new Invoice__c();
        inv.Account__c=acc.id;
        inv.CurrencyIsoCode='USD';
        inv.Project__c=prj.id;
        inv.Sub_Contractor_Employee__c=emp.id;
        inv.Service_Term_From__c=Date.Today().addDays(-7);
        inv.Service_Term_To__c=Date.Today().addDays(7);
        inv.Amount__c=10000;
        insert inv;


        Timecard__c tc= new Timecard__c();
        tc.Employee__c = emp2.id;
        tc.Project__c = prj.id;
        tc.Total__c = 1000;
        tc.Status__c = 'Approved';
        tc.Hours__c = 10;
        tc.Client_Pay__c=100;
        tc.Invoice__c = inv.Id;
        tc.Date_Of_Service__c = Date.today();
        system.debug('==================='+ tc.Date_Of_Service__c);
        System.debug('Time card = ' + tc);
        insert tc;

        Timecard__c tc1 = new Timecard__c();
        tc1.Employee__c=emp2.id;
        tc1.Project__c=prj.id;
        tc1.Total__c=1000;
        tc1.Status__c='Approved';
        tc1.Hours__c=10;
        tc1.Client_Pay__c=100;
        tc1.Date_Of_Service__c = Date.today();
        system.debug('==================='+ tc1.Date_Of_Service__c);
        System.debug('Time card = ' + tc1);
        insert tc1;

        System.debug('lstTimeCard = ' + [SELECT Id, Client_Pay__c, Client_Pay_Per_Day__c FROM Timecard__c]);

        /**Timecard__c tc1=new Timecard__c();
        tc1.Employee__c=emp2.id;
        tc1.Project__c=prj.id;
        tc1.Invoice__c=inv.id;
        tc1.Total__c=1000;
        tc1.Status__c='Approved';
        tc1.Hours__c=10;
        tc1.Client_Pay__c=100;
        tc1.Date_Of_Service__c=Date.Today().addDays(-40);
        system.debug('==================='+ tc.Date_Of_Service__c);
        Insert tc1;**/



        list<Timecard__c >lstTimeCards =[select id, name ,Timecard__c.project__r.name,Timecard__c.project__r.Account_Manager__r.Name,project__r.owner.name, Work_Description__c,
                   Timecard__c.Employee__r.Name,Date_Of_Service__c,Balance_Due__c, Hours__c, invoice__r.Service_Term_From__c,invoice__r.Service_Term_To__c,
                    Client_Pay__c from Timecard__c where project__c =:inv.Project__c and Date_Of_Service__c >= :inv.Service_Term_From__c and Date_Of_Service__c  <= :inv.Service_Term_To__c order by Employee__c];
        system.debug('==================='+lstTimeCards );



        list<Account>accRec=[SELECT Id, Name,BillingStreet, BillingCity, BillingState,
            BillingPostalCode, BillingCountry FROM Account WHERE Id=:acc.id];

        Test.setCurrentPage(Page.ShowAllTimecards2);
        ApexPages.currentPage().getParameters().put('id',inv.id);
        ApexPages.StandardController sc = new ApexPages.standardController(inv);
        ShowallTimeCatdsCtrl2 objTimecrd = new ShowallTimeCatdsCtrl2(sc);
        ShowallTimeCatdsCtrl2.timeCardWrapClass tem = new ShowallTimeCatdsCtrl2.timeCardWrapClass();
        //ShowallTimeCatdsCtrl2.wrapclass tem1=new ShowallTimeCatdsCtrl2.wrapclass(lstToInsert[0],123,'hi',123);

        objTimecrd.onload();
        objTimecrd.calculateData();
        objTimecrd.check = false;
        objTimecrd.empname = emp2.Name;
        objTimecrd.headCheckselection();
        objTimecrd.calculateData();
        objTimecrd.check = true;
        objTimecrd.headCheckselection();
        objTimecrd.calculateData();
        objTimecrd.eeName = emp2.Name;
        objTimecrd.subCheck = false;
        objTimecrd.ChildCheckSelection();
        objTimecrd.calculateData();
        objTimecrd.subCheck = true;
        objTimecrd.ChildCheckSelection();
        objTimecrd.calculateData();
        objTimecrd.eName = emp2.Name;
        objTimecrd.calculateEmpDataSub();
        objTimecrd.selectcheckbox();
        objTimecrd.timecards();
        objTimecrd.generateinvoice();
        objTimecrd.saveinvoice();
        objTimecrd.sendPdf();
        objTimecrd.downloadPDF();
        objTimecrd.saveandnew();
        objTimecrd.cancelInv();
        objTimecrd.getallAttachments();
        objTimecrd.getalTimecrds();
        objTimecrd.calculateDataAmount();
        objTimecrd.selectDeselect();
        objTimecrd.dosave();
        objTimecrd.redirectInvPage();
        System.debug(objTimecrd.parentCheckBoxVal);
        System.debug(objTimecrd.recordTypename);
        System.debug(objTimecrd.isExport);
        System.debug(objTimecrd.totalAmount);
        System.debug(objTimecrd.allBool);
        System.debug(objTimecrd.product);
        System.debug(objTimecrd.defalval);
        System.debug(objTimecrd.attachment);
        System.debug(objTimecrd.newwrap.hoursAndUnitprice);
        System.debug(objTimecrd.newwrap.totHrs);
    }
}

 
SELECT  Id,
                                                Name,
                                                Project__c,
                                                Employee__c,
                                                Client_Pay__c,
                                                Client_Pay_Per_Day__c,
                                                Hours__c,
                                                Date_Of_Service__c,
                                                Invoice__c
                                        FROM    Timecard__c
                                                
                                        WHERE   Employee__c IN  :empids 
                                            AND project__c = :objInvoices.Project__c
                                            AND Date_Of_Service__c >= :objInvoices.Service_Term_From__c
                                            AND Date_Of_Service__c  <= :objInvoices.Service_Term_To__c
                                           order by  Date_Of_Service__c desc ];

 
trigger PayoffExpenses on Invoice__c (after update) {
    Set<id> invids=new Set<id>();
    for(Invoice__c i:trigger.new){
        if(i.Status__c=='Paid' && trigger.oldmap.get(i.id).status__c!='Paid')
            invids.add(i.Id);
    }
    List<Expense__c> exp=[Select id,Client_Status__c,Invoice__c from Expense__c where 
                         Invoice__c IN : invids and Status__c!='Paid Off'];
    for(Expense__c ep:exp)
        ep.Client_Status__c='Paid';
    update exp;
}
<apex:page standardStylesheets="false" id="pge" applyHtmlTag="false" applyBodyTag="false" showHeader="false" standardController="Invoice__c" extensions="showallTimeCatdsCtrl2" renderAs="pdf" cache="false">
<head>
    <style>
        @page {
            margin-top: 7cm;
            margin-bottom: 4cm;

            @top-center {
                content: element(header);
            }
            @bottom-left {
                content: element(footer);
            }
        }

        div.header {
            padding: 10px;
            position: running(header);
        }
        div.footer {
            display: block;
            padding: 1%;
            position: running(footer);
           
        }
        .pagenumber:before {
            content: counter(page);
        }
        .pagecount:before {
            content: counter(pages);
        }
        div.content {
            border-style:
            float: left;
            width: 100%;
        }
    </style>
</head>

<!-- 1.HEADER -->
<div class="header">
    <apex:image value="{!$Resource.ATSLogo1}" width="240" height="120" style="text-align:center; padding-left:210px; " />
    
    <table style="width:80%;" >
                    <tr>
                        <td style="text-align:center; font-size:15px; margin-top:200px;">
                            <h1  style = "color:#959595;"> <u>INVOICE</u></h1>
                        </td>
                    </tr>
                </table>  
                  <span style = "font-size:13px;" >  &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;    <br> <apex:outputText value="{0, date, MMMM d','  yyyy}" >
                &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;   &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;  &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<apex:param value="{!now()}"  /> 
                </apex:outputText></br>
           
            <br>  &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;  &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;  &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;  &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;  &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;  &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;  &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;  &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;  &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;   &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;  &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;  &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;  INVOICE#:{!newInvoic.Name}</br>
       
        </span>
         <apex:image value="{!$Resource.Logo}" width="11cm" height="29.7" style="margin-left:10.5cm;margin-top:12cm; " />
        <!--<apex:outputPanel>
     <img src="{!URLFOR($Resource.Logo)}" style="position: fixed; left: 11.5cm; top:19cm; background-repeat:repeat;" width="11cm" height="29.7"/>
   </apex:outputPanel>-->


   </div>     
<!-- 2.FOOTER -->
<div class="footer" style="margin-top:82px;">
 
  
  <!-- <div style="background-color:#2E3640; color:white; width:70%; height:70px; border-radius:60px;font-size:12px;position:running; top:900px;margin-left:30px;width:92%" ><p><br>&nbsp; &nbsp;&nbsp;  &nbsp;Access Technology Solutions Inc. &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp; &nbsp;  &nbsp;&nbsp;&nbsp;     Ph: 1.800.637.9569, &nbsp; Fax: 1.800.637.9569 </br>
  <br> </br>
<br>&nbsp;&nbsp; &nbsp; www.Accesstechnologys.com &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; CONFIDENTIAL    &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;    Email:Info@accesstechnologys.com</br></p></div>
<br> </br>-->
     <span style="margin-left:60px;color:#566068;font-size:16px;font-family:Batang;"> P. 800.637.9569 E. info@accesstechnologys.com W. www.accesstechnologys.com
     </span>
     <br/><br/>
     <br/>
    
     <span style="background-color:#0d1428;width:30cm;height:20px;display: block;margin-left:-60px;"></span>
     
</div>

<!--3.
CONTENT -->
<div class="content">


   <p style= "font-size:12px;margin-left:30px;top:10%; ">  <b>From :</b> &nbsp;  <b> Access Technology Solutions Inc.</b>
       <br>  &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;141 W. Jackson Blvd..,</br>
       <br>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;Ste. 3810,</br>
       <br>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;Chicago, IL 60604,</br>
       <br>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;Ph.: (312) 529-5159.</br></p>
  
<p style= "font-size:12px;margin-left:30px;"> <b> To  &nbsp; &nbsp;  :  &nbsp; &nbsp;{!tcs[0].accountname__c}</b>

<br> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;{!tcs[0].accountbillingcity__c}</br>
<br> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;{!tcs[0].accountbillingstate__c}</br>
<br> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;{!tcs[0].accountbillingcity__c}</br>
<br> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;{!tcs[0].accountbillingPin__c}</br></p>
<br></br>
<table width="92%" height="auto" style="border:solid #000 0.5px; border-collapse: collapse; font-size:12px;margin-left:30px;">
    <tr style ="background-color:#959595; text-align:center;">
        <td style="border:solid #000 0.5px; "><b>Project Associate</b></td>
        <td style="border:solid #000 0.5px;"><b>Project</b></td>
        <td style="border:solid #000 0.5px;"><b>Service  Terms</b></td>
        <td style="border:solid #000 0.5px;"><b>Due Date</b></td>
    </tr>
    <apex:repeat value="{!selectedtimecards[0]}" var="sel">
        <tr style = "text-align:center;">
            <td style="border:solid #000 0.5px; ">{!sel.tc.project__r.owner.Name}</td>
           <td style="border:solid #000 0.5px;">{!sel.tc.project__r.name}</td>
            <td style="border:solid #000 0.5px;">{!sel.serviceTims}</td>
            <td style="border:solid #000 0.5px;"><apex:outputText value="{0,date,MM'/'dd'/'yyyy}" >
                <apex:param value="{!sel.tc.Date_Of_Service__c}"  /> 
                </apex:outputText></td>
            
        </tr>
    </apex:repeat>                             
</table><br/>
<table class="fixed" width="92%" height="auto" style="border:solid #000 0.5px; border-collapse: collapse; font-size:12px; margin-left:30px;">
    <tr style ="background-color:#959595; text-align:center;">
        <td style="border:solid #000 0.5px;width: 20%;"><b>Employee Name</b></td>
        <td style="border:solid #000 0.5px;width: 20%;"><b>Description</b></td>
        <td style="border:solid #000 0.5px;width: 20%;"><b>Hours</b></td>
        
        <td style="border:solid #000 0.5px;width: 20%;"><b>Unit Price</b></td>
        <td style="border:solid #000 0.5px;width: 20%;"><b>Amount</b></td>
    </tr>
    <apex:repeat value="{!selectedtimecardsWrpr}" var="var">
        <tr  style = "text-align:center;">
            <td style="border:solid #000 0.5px;width: 20%;">{!var.empName}</td>
            <td style="border:solid #000 0.5px;width: 20%;">{!var.decption}</td>
            <td style="border:solid #000 0.5px;width: 20%;">{!var.totHrs}</td>
            <td style="border:solid #000 0.5px;width: 20%;">{!var.hoursAndUnitprice}</td>
            <td style="border:solid #000 0.5px;width: 20%;">{!var.totalAmt}</td>
        </tr>
    </apex:repeat>
</table>

<table style="width:17cm; height:auto;margin-left:30px;">
    <tr>
         <td style = "width:11cm;font-size:15px;">
       <br/>
        Comments: {!objInvoices.Comments__c}
        
        </td>
        <td style="width:7cm;">
            <table style="width:103%; border:solid #000 0.5px; border-collapse: collapse; " >
                <tr >
                    <td style="width:50%;font-size:13px;border:solid #000 0.5px;"><b>Total</b></td>
                    <td style="width:50%;font-size:13px;border:solid #000 0.5px;text-align:center;">$ {!grandTotal}</td>   
                </tr>
                <tr>
                    <td style="width:50%;font-size:13px; border:solid #000 0.5px;"><b>Payment/Credit</b></td>
                    <td style="width:50%;font-size:13px; border:solid #000 0.5px;text-align:center;">$ {!payments}</td> 
                </tr>
                <tr>
                    <td style="width:50%;font-size:13px; border:solid #000 0.5px;"><b>Due</b></td>
                    <td style="width:50%;font-size:13px; border:solid #000 0.5px;text-align:center;">$ {!grandTotal-payments}</td>  
                </tr>
            </table>
        </td>
       
    </tr>
</table>
<!-- 
    <apex:outputLabel ><br>Comments :</br></apex:outputLabel>
<br> <apex:inputTextarea style="width:55%;font-size:13px;"  value="{!objInvoices.Comments__c}"/></br>
</apex:pageBlock>-->
<p style="font-size:13px; margin-left:30px;">
<br> Make all checks payable to <b>Access Technology Solutions, Inc</b></br>
<br>Remit your payments to the above address. If wiring, send them to  Chase,</br> 
<br>Acct# 181395661 R/T Number: 071000013. Chicago, IL 60604 USA</br></p>


<apex:outputText > <h4 style="text-align:center; margin-left:80px;;"> 
    
     Thank you for your business!</h4></apex:outputText>
   
</div>
</apex:page>
public with sharing class showallTimeCatdsCtrl {

public Invoice__c objInvoices {get;set;}

public Invoice__c obj  {get;set;}
public string recordTypeId {get;set;}
public string RecordTypename{get;set;}
public string  strProjectId{get;set;}
public date fromDate{get;set;}
public date toDate{get;set;}
public List<Timecard__c> lstTimeCards {get;set;}
public List<showallTimeCatdsCtrlwrapper> TcList = new List<showallTimeCatdsCtrlwrapper>();
public List<Timecard__c> selectedlstTimecards = new List<Timecard__c>();

 public showallTimeCatdsCtrl(ApexPages.StandardController controller) {
     objInvoices = new invoice__c ();
    obj = new invoice__c ();
    recordTypeId = ApexPages.currentPage().getParameters().get('RecordType');
    
    List<recordtype> lstRecordtypeName = [select id,name from recordtype where SobjectType ='invoice__c' and id=:recordTypeId limit 1 ];
    RecordTypename = lstRecordtypeName[0].name;   
    lstTimeCards  = new List<Timecard__c>();
        //obj=[select id,name,CurrencyIsoCode,recordtypeid from invoice__c where recordtypeid= :recordTypeId  limit 1];

    }
     
       public PageReference saveInvoices() {        
        strProjectId = objInvoices.Project__c;   
        objInvoices.recordtypeid = recordTypeId ;
        fromDate      =     objInvoices.Service_Term_From__c; 
        todate        =     objInvoices.Service_Term_To__c;
        
        upsert objInvoices;
        
        if(strProjectId!=null){
        
        lstTimeCards  =[select id, name ,project__c ,Employee__c, Date_Of_Service__c, Hours__c, invoiced__c, Client_Pay__c from Timecard__c where project__c  = :strProjectId and Date_Of_Service__c >= :fromDate  and Date_Of_Service__c  <= : todate];
         TcList.add(new showallTimeCatdsCtrlwrapper(Tc));
        return null;

          }  
       
        return null;
    }
    public PageReference getSelected()

    {

        selectedlstTimecards.clear();

        for(showallTimeCatdsCtrlwrapper Tcwrapper : TcList)

        if(Tcwrapper.selected == true)

        selectedlstTimecards.add(Tcwrapper.Tc);

        return null;

    }
        public PageReference Generate(){
        PageReference pageRef = new PageReference('/apex/editable');
        pageRef.setRedirect(false);
        return pageRef;
    }
    
    public class showallTimeCatdsCtrlwrapper

    {
        public Timecard__c Tc{get; set;}

        public Boolean selected {get; set;}

        public showallTimeCatdsCtrlwrapper(Timecard__c a)

        {

           Tc = a;

            selected = false;

        }

    }



}


Hi,
Employee name, Time card id, date of service, hours, client pay are record colummns , i wanted to display timecards based on employee name , how to achieve this, pl help me  

 custom list records display
 Thanks,

Deepu

public with sharing class showallTimeCatdsCtrl {

public Invoice__c objInvoices {get;set;}

public Invoice__c obj  {get;set;}
public string recordTypeId {get;set;}
public string RecordTypename{get;set;}
public string  strProjectId{get;set;}
public date fromDate{get;set;}
public date toDate{get;set;}
public List<Timecard__c> lstTimeCards {get;set;}
public List<showallTimeCatdsCtrlwrapper> TcList = new List<showallTimeCatdsCtrlwrapper>();
public List<Timecard__c> selectedlstTimecards = new List<Timecard__c>();

 public showallTimeCatdsCtrl(ApexPages.StandardController controller) {
     objInvoices = new invoice__c ();
    obj = new invoice__c ();
    recordTypeId = ApexPages.currentPage().getParameters().get('RecordType');
    
    List<recordtype> lstRecordtypeName = [select id,name from recordtype where SobjectType ='invoice__c' and id=:recordTypeId limit 1 ];
    RecordTypename = lstRecordtypeName[0].name;   
    lstTimeCards  = new List<Timecard__c>();
        //obj=[select id,name,CurrencyIsoCode,recordtypeid from invoice__c where recordtypeid= :recordTypeId  limit 1];

    }
     
       public PageReference saveInvoices() {        
        strProjectId = objInvoices.Project__c;   
        objInvoices.recordtypeid = recordTypeId ;
        fromDate      =     objInvoices.Service_Term_From__c; 
        todate        =     objInvoices.Service_Term_To__c;
        
        upsert objInvoices;
        
        if(strProjectId!=null){
        
        lstTimeCards  =[select id, name ,project__c ,Employee__c, Date_Of_Service__c, Hours__c, invoiced__c, Client_Pay__c from Timecard__c where project__c  = :strProjectId and Date_Of_Service__c >= :fromDate  and Date_Of_Service__c  <= : todate];
         TcList.add(new showallTimeCatdsCtrlwrapper(Tc));
        return null;

          }  
       
        return null;
    }
    public PageReference getSelected()

    {

        selectedlstTimecards.clear();

        for(showallTimeCatdsCtrlwrapper Tcwrapper : TcList)

        if(Tcwrapper.selected == true)

        selectedlstTimecards.add(Tcwrapper.Tc);

        return null;

    }
        public PageReference Generate(){
        PageReference pageRef = new PageReference('/apex/editable');
        pageRef.setRedirect(false);
        return pageRef;
    }
    
    public class showallTimeCatdsCtrlwrapper

    {
        public Timecard__c Tc{get; set;}

        public Boolean selected {get; set;}

        public showallTimeCatdsCtrlwrapper(Timecard__c a)

        {

           Tc = a;

            selected = false;

        }

    }



}
i have uploaded outbound change set to production but while deploying it showing 2 errors.User-added image
Trigger is:
Trigger FieldUpdateEmail on Opportunity (Before insert,Before update)
{  
    set<id> conid=new set<id>();
    List<Contact> con=[Select id,Name from Contact];

    for(Contact c:con)
    {
        conid.add(c.id);  
    }
    List<Id> idd=new List<Id>();
     
    for(Opportunity oo:Trigger.New){
     conId.add(oo.Contact__c);
    }
    Map<ID, Contact> m = new Map<ID, Contact>([SELECT Id,Solicitor__r.Email_Id__c,Solicitor__c,Solicitor__r.First_Name__c,Solicitor__r.Last_Name__c FROM Contact where id In:conId]);
  for(Opportunity oo:Trigger.New){
   oo.TestEmail__c=m.get(oo.Contact__c).Solicitor__r.Email_Id__c;
   oo.Solicitor_FullName__c=m.get(oo.Contact__c).Solicitor__r.First_Name__c + ' '+ m.get(oo.Contact__c).Solicitor__r.Last_Name__c;
 //   oo.Solicitor__c=m.get(oo.Contact__c).Solicitor__c;
    }
  
}

Solicitor__c is a lookup field on contact. also solicitor is custom object whose API name is Solicitor__c.
Hi I am trying to merge two or more pdfs in one pdf in Salesforce, I looked into many things and searched allot but didn't got anything.
If anybody have done any POC on this thing do let me know.

Thanks
I have a requirement to merging PDF documents.Product related documents uploaded by admin in documents/files.Based on a selection of user (2 out of 10) , selected documents needs to be merged in single PDF. 
Has anybody done this previously? Is there any appexchange app available to do this?

Hi,

 

I want to merge static pdf file and pdf file generated by visualforce page.

 

Please suggest the solution

 

Thanks in Advance,

Anil

Hi we have requirement where we have to generate COF using visual force page  and attach/merge  documents attached under Notes/Attachment (Solution  Defenition document) section of opportunity . Here i want to know do we have any functionality in VF where we can attach PDFs to  COF PDF generated using visual force page

There is a requirement that instead of generating more pdf files for all customer, can we combine all the files into a single PDF files or a zip file using Apex code

Hi there. I'm wondering if anybody in the past has merged 2 or more pdf files using the getContent()

method or something similar? Is this possible?

Thanks

  • February 24, 2009
  • Like
  • 0