0

NotifyChanges Not Working In @Listen Event

asked 2014-09-23 14:25:20 +0800

sathishk gravatar image sathishk
17 5

updated 2014-09-24 06:36:18 +0800

chillworld gravatar image chillworld flag of Belgium
5357 4 9
https://github.com/chillw...

This Is My Zul File I am using this code. @command to Notify changes done successfully,but when i use @Listen event its not working properly,please help hoe can i rectify this. I have issue on billing plan Link.Please Help me

<zk xmlns:h="native"> <window id="win" border="none" apply="org.novelerp.controller.DashboardUIController" xmlns:d="&lt;a href=" http:="" www.zkoss.org="" 2005="" zk="" client="" attribute"="">http://www.zkoss.org/2005/zk/client/attribute">

<h:ul>

            <h:li class="shipment" style="margin-top:0px !important;" if="${sessionScope.isCustomer}">
                <a id="customerlink">My Profile</a>
            </h:li>
            <h:li class="open" if="${sessionScope.isCustomer}"><a id="projectlink">Project Overview</a></h:li>
            <h:li class="transaction" if="${sessionScope.isCustomer}"><a id="gallerylink">Construction Status</a></h:li>
            <h:li class="financial" if="${sessionScope.isCustomer}"><a id="payment">Statement of Account</a></h:li>
            <h:li class="dispatch" if="${sessionScope.isCustomer}"><a id="dispatch">Dispatch Details</a></h:li>
            <h:li class="refer" if="${sessionScope.isCustomer}"><a id="referlink">Refer a Friend</a></h:li>
            <h:li class="Writelink" if="${sessionScope.isCustomer}"><a href="" id="writelink">Service Requests</a></h:li>
            **<h:li class="gu no-border" if="${sessionScope.isCRCAdmin}"><a id="bplanlink">Billing Plan</a></h:li>**
        </h:ul>
    </div>
    <tabbox mold="accordion" apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('org.novelerp.controller.DashboardUIController')">
        <tabs>
        <tab sclass="user_information" id="tabmyprofile" selected="true" style="font-size: 13px;" if="${sessionScope.isCustomer}"> My Profile </tab>
        <tab sclass="pro_overview" id="tabproject" visible="false" style="font-size: 13px;" if="${sessionScope.isCustomer}"> Project Overview</tab>
        <tab sclass="gallery_icon" id="tabgalery" visible="false" style="font-size: 13px;" if="${sessionScope.isCustomer}">Construction Status</tab>
        <tab sclass="pay_details" id="tabaccount" visible="false" style="font-size: 13px;" if="${sessionScope.isCustomer}">Statement of Account</tab>
        <tab sclass="dispatch" id="tabdispatch" visible="false" style="font-size: 13px;" if="${sessionScope.isCustomer}">Dispatch Details</tab>
        <tab sclass="refer" id="tabrefer" visible="false" style="font-size: 13px;" if="${sessionScope.isCustomer}">Refer a Friend</tab>
            **<tab sclass="gu" id="tabbplan" style="font-size: 13px;" if="${sessionScope.isCustomer}" visible="false">Billing Plan</tab>**
        </tabs>
        <tabpanels>
            <tabpanel id="customerDetails" if="${sessionScope.isCustomer}">
                <div class="user_details">
                    <div class="user_img">
                     <button image="${customer.image1}" id="image2" upload="true,maxsize=1024">
                     </button>

                        <h:div class="text_hover">Test for mouse hover text.</h:div>

                    </div>
                    <div class="fleft">
                        <h:div class="name"><label style="font-weight: bold;font-size: 16px;" value="@bind(vm.customer.firstName)" id="firstname"></label></h:div>

                        <div style="margin-top:61px;" apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('org.novelerp.controller.UpdateProfileController')">
                            <button sclass="btn_image reset_btn" onClick="@command('editProfilePopup')">
                                Update Details
                            </button>
                        </div>

                    </div>
                    <div class="clearboth"></div>
                </div>
                <div class="flat_bg">
                    <div style="padding: 7px 4px 7px 9px;"> 
                        <h:div>Personal Details </h:div>
                    </div>
                </div>
                <div class="user_info" style="height: 44px;">
                    <h:ul>
                        <h:li>
                            <h:label>Name</h:label>
                            <h:span><label value="@bind(vm.customer.firstName)" id="name"></label></h:span>
                        </h:li>
                        <h:li>
                            <h:label>Customer Code</h:label>
                            <h:span><label value="@bind(vm.customer.customerCode)" id="custcode"></label></h:span>
                        </h:li>
                        <h:li>
                            <h:label>Birth Date</h:label>
                            <h:span><label value="@bind(vm.myprofilecrc.birthdate)" id="birthdate"></label></h:span>
                        </h:li>
                    </h:ul>
                    <div class="clearboth"></div>
                </div>
                <div class="clearboth"></div>
                <div class="flat_bg">
                    <div style="padding: 7px 4px 7px 9px;"> 
                        <h:div>Contact Details </h:div>
                    </div>
                </div>
                <div class="user_info">
                    <h:ul>
                        <h:li>
                            <h:label>Mobile Number</h:label>
                            <span id="smobnumber">
                            <label value="@bind(vm.myprofilecrc.mobilenumber)" id="mobileno1"></label>
                            </span>

                        </h:li>
                        <h:li>
                            <h:label>Telephone Number</h:label>
                            <span id="stelphone">
                            <label value="@bind(vm.myprofilecrc.telephonenumber)" id="telno"></label>
                            </span>

                        </h:li>
                        <h:li>
                            <h:label>Email</h:label>
                            <span id="semail"><label value="@bind(vm.myprofilecrc.email)" id="email"></label></span>
                        </h:li>
                        <h:li>
                            <h:label>State </h:label><h:span><label value="@bind(vm.myprofilecrc.state)" id="state1"></label></h:span>
                        </h:li>
                        <h:li>
                            <h:label>Postal Code </h:label> <h:span><label value="@bind(vm.myprofilecrc.postalcode)" id="postalcode"></label></h:span>
                            <div class="clearboth"></div>
                        </h:li>

                        <h:li class="marg_right0 marg_bottom0" style="width:100% !important;">
                            <h:ul>
                                <h:li class="marg_bottom0">
                                    <h:label>Present Address </h:label>
                                    <span id="presentspan"><label value="@bind(vm.myprofilecrc.presentaddress)" id="presentaddress"></label></span>
                                    <textbox id="presntaddress" visible="false" multiline="true"></textbox>
                                </h:li>
                                <h:li class="marg_bottom0">
                                    <h:label> Permanent Address </h:label>
                                    <span id="preferedspan"><label value="@bind(vm.myprofilecrc.perminentaddress)" id="perminentaddress"></label></span>
                                </h:li>
                            </h:ul>
                        </h:li>
                    </h:ul>
                    <div class="clearboth"></div>
                </div>
                <div class="clearboth"></div>

                <div class="flat_bg">
                    <div style="padding: 7px 4px 7px 9px;"> 
                        <h:div>Flat Details </h:div>
                    </div>
                </div>

                <div class="user_info">
                    <h:ul>
                        <h:li>
                            <h:label>Booking ID </h:label><!-- <h:span>${flat.bookingid}</h:span> -->
                            <h:span><label value="@bind(vm.flat.bookingid)" id = "bookingid"></label></h:span>
                        </h:li>
                        <h:li>
                            <h:label>Project</h:label><!-- <h:span>${flat.projectname}</h:span> -->
                            <h:span><label value="@bind(vm.flat.projectname)" id = "projectname1"></label></h:span>
                        </h:li>
                        <h:li>
                            <h:label>Allotment Date</h:label>
                            <h:span><label value="@bind(vm.flat.allotmentdate)" id = "allatment"></label></h:span>
                        </h:li>
                        <h:li>
                            <h:label>Flat No</h:label>
                            <h:span><label value="@bind(vm.flat.flatno_flatid)" id = "flatno"></label></h:span>
                        </h:li>
                        <h:li>
                            <h:label>Flat Type</h:label><h:span>
                            <label value="@bind(vm.flat.flattype)" id = "flattype"></label></h:span>
                        </h:li>
                        <h:li>
                            <h:label>Agreement Reg. Date</h:label><h:span>
                            <label value="@bind(vm.flat.aggreementregdate)" id = "agreement"></label></h:span>
                        </h:li>
                        <h:li>
                            <h:label>Basic Cost</h:label><h:span>
                            <label value="@bind(vm.flat.considerationvalue)" id = "consideration"></label></h:span>
                        </h:li>
                        <h:li>
                            <h:label>Tower</h:label><h:span><label value="@bind(vm.flat.wing)" id = "wing"></label></h:span>
                        </h:li>
                        <h:li if="${sessionScope.isCRCAdmin}">
                            <h:label>Project Code</h:label><h:span><label value="@bind(vm.flat.projectcode)" id = "pcode"></label></h:span>
                        </h:li>
                    </h:ul>
                    <div class="clearboth"></div>
                </div>
            </tabpanel>

            <tabpanel id="projectview" if="${sessionScope.isCustomer}">

                <div class="overview">
                    <div>   
                        <div class="left_img">
                            <div> 
                                <image class="pro_img" src="@bind(vm.overview.image)" id="imageicon"></image>
                            </div>
                        </div>
                        <div class="detail_right">
                            <div>
                                <image  src="@bind(vm.overview.project_logo)" id="project_logo"></image>
                            </div>
                            <div class="txtjustify">
                                <h:p class="pro_about"><label value="@bind(vm.overview.description)" id="description1"></label></h:p>
                            </div>
                        </div>
                        <div style="text-align:right;">
                             <a href="@bind(vm.overview.url)" target="_blank" id="url" class="more_info" >Click for more info</a>
                        </div>
                        <div class="clearboth"></div>
                    </div>

                    <div class="highlight">
                        <div class="inner_title">
                            <h:div class="arrwo">Project Highlights </h:div>
                        </div>
                        <div class="clearboth"></div>
                    </div>
                    <div class="clearboth"></div>
                </div>
            </tabpanel>
            <!-- Latest Image Gallery -->
            <tabpanel id="gallery" if="${sessionScope.isCustomer}">
                    <!-- Year Filter -->
                    <h:div style="padding:15px 15px 0px 15px;">
                        <div class="fright">
                            <h:span class="bold">Select Year </h:span>
                            <listbox mold="select" model="@load(vm.years)"  onSelect="@command('yearSelect' , ref=self.selectedItem)"> <!--  onSelect="@command('yearSelect' , ref=self.selectedItem)" onselect Added by shrikant  -->
                                <template name="model">
                                    <listitem value="@load(each.yValue)" label="@load(each.yName)" selected="@load(each.selected)"></listitem>
                                </template>
                            </listbox>

                        </div>
                        <div class="clearboth"></div>
                    </h:div>    
                    <!-- END Year Filter -->


                    <!-- Tab Panel New -->    
                        <div class="tab_p" >
                            <h:ul class="uact">
                                <div children="@load(vm.months)">
                                    <template name="children" var ="node">
                                        <h:li>
                                            <a sclass="activator" onClick="@command('showImages', ref=self.label, iref = self.uuid )" label="@load(node.mName)"> </a>
                                        </h:li>
                                    </template>
                                </div>
                            </h:ul>
                            <div class="clearboth"></div>   
                        </div>

                        <div class="tab_scroll" >
                            <h:ul >
                                <div children="@load(vm.imgList)" >
                                    <template  name="children" var="inode">
                                        <h:li class="project_box">
                                            <a class="month_g cboxElement" href="@load(inode.large)" d:title="${inode.imagename}" > 
                                                <image src="@load(inode.thumb)" />
                                                <h:div>${inode.imagename}</h:div>
                                            </a>
                                        </h:li>
                                    </template>
                                </div>
                            </h:ul>
                            <div class="clearboth"></div>
                        </div>

                    <!-- END Tab Panel New -->    
                    <!-- END inner-box-->

                    <div class="clearboth"></div>
            </tabpanel>

            <!-- END Latest Image Gallery -->

            <!-- Track Progress -->
            <!-- <tabpanel id="trackprogress">
                <div align="center">
                    <h:img src="css/images/12key-animation.gif" alt="" title="Graph"/>
                </div>
            </tabpanel> -->
            <!-- END Track Progress -->

            <!-- Account Statement -->
            <tabpanel id="filterLayout1" if="${sessionScope.isCustomer}">
                <div class="user_info">
                    <div class="marg_bottom10">
                        <h:ul>
                            <h:li>
                                <h:label>Project Name </h:label><h:span><label value="@bind(vm.summary.projectName)" id="projectsummary"></label></h:span>
                            </h:li>
                            <h:li>
                                <h:label>Flat Code </h:label><h:span><label value="@bind(vm.summary.flatcode)" id="flatcodesummary"></label></h:span>
                            </h:li>
                            <h:li>
                                <h:label>Customer Code </h:label><h:span><label value="@bind(vm.summary.customercode)" id="ccodesummary"></label></h:span>
                            </h:li>
                            <h:li>
                                <h:label>Total Billed / Invoiced </h:label> <h:span><label value="@bind(vm.summary.totalcost)" id="totalsummary"></label></h:span>
                            </h:li>
                            <h:li>
                                <h:label>Paid Amount  </h:label><h:span><label value="@bind(vm.summary.paidamount)" id="paidsummary"></label></h:span>
                            </h:li>
                            <h:li>
                                <h:label>Balance Amount</h:label><h:span><label value="@bind(vm.summary.balanceamount)" id="balancesummary"></label></h:span>
                            </h:li>

                        </h:ul>
                        <div class="clearboth"></div>
                    </div>
                    <div class="clearboth"></div>
                    <div if="${sessionScope.isCustomerCare}">
                        <div class="user_info" apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('org.novelerp.controller.DashboardUIController')">
                            <h:ul>
                                <h:li>
                                    <h:label>Project Name<h:strong style="color:red;">* </h:strong></h:label>
                                    <listbox model="@load(vm.projectNames)" mold="select" selectedItem="@bind(vm.pname)" onSelect="@command('onProjectSelect')">
                                        <template name="model">
                                            <listitem label="@load(each.projectname)" value="@load(each.projectcode)"></listitem>
                                        </template> 
                                    </listbox>
                                </h:li>
                                <h:li>
                                    <h:label>Tower Name<h:strong style="color:red;">* </h:strong></h:label>
                                    <listbox model="@load(vm.towerDisplayList)" mold="select" selectedItem="@bind(vm.tname)" onSelect="@command('onTowerSelect')">
                                        <template name="model">
                                            <listitem label="@load(each.towername)" value="@load(each.towercode)"></listitem>
                                        </template> 
                                    </listbox>
                                </h:li>
                                <h:li>
                                    <h:label>Flat Code<h:strong style="color:red;">* </h:strong></h:label>
                                    <listbox model="@load(vm.flatcodeDisplay)" mold="select" selectedItem="@bind(vm.fcode)" onSelect="@command('onCustomerSelect' , ref=self.selectedItem)">   
                                        <template name="model">
                                            <listitem label="@load(each.flatcode)" value="@load(each.customercode)"></listitem>
                                        </template> 
                                    </listbox>
                                </h:li>

                            </h:ul>
                        </div>
                        <div class="clearboth"></div>
                        <div >
                            <button class="export_data" id="finddetails">Find Details</button>
                        </div>
                    </div>
                    <div class="clearboth"></div>
                    <div>
                        <div if="${sessionScope.isCustomer}">
                            <button class="export_data" id="beforesubmit">Details</button>
                        </div>
                        <div>
                             <button class="export_data" id="aftersubmit" visible="false">Hide Details</button>

                            <button id="export_pdf" class="export_data" label="Export to pdf" visible="false" target="_blank"></button>
                            <button id="export_exel" class="export_excel" label="Export to excel" visible="false" onClick="@command('exportGridToExcel', ref=paymentDetailGrid)"></button>
                        </div>
                    </div>  
                </div>
                <div class="clearboth"></div>

                <!-- Payment Details filter -->
                    <div id="filter" visible="false">
                        <h:ul class="padd10 payment_filter">
                            <h:li>
                                <h:label> Date </h:label>
                                <datebox id="fromDate1" format="dd.MM.yyyy" mold="rounded" constraint="no future"></datebox>
                            </h:li>
                            <h:li>
                                <h:label> To </h:label>
                                <datebox id="toDate1" format="dd.MM.yyyy" mold="rounded" constraint="no future"></datebox>
                            </h:li>
                            <h:li class="marg_top0">
                                <button id="searchShip1" class="button marg-0">Submit</button>
                            </h:li>
                            <div class="clearboth"></div>
                        </h:ul>
                    </div>
                    <div class="clearboth"></div>

                <div class="replace_border">
                    <grid id="paymentDetailGrid" height="300px" vflex="1" emptyMessage="No record found" visible="false">
                     </grid>
                    <div class="clearboth"></div>
                </div>
                <div class="clearboth"></div>

                <div class="" id="terms" visible="false">

                    <h:ul class="dis">
                        <h:li class="dis_title">
                            Disclaimer
                        </h:li>

                        <h:li>
                            <h:strong class="red">* </h:strong>
                            <label>This statement does not include interest or any other charges,If applicable. Please contact your relationship manager for exact details</label>
                        </h:li>

                        <h:li>
                            <h:strong class="red">*</h:strong>
                            <label>Computer generated statements do not require any official signature. This portal represents our record of transactions with you. You are requested to notify us if you find any discrepancies mentioned.</label>
                        </h:li>
                    </h:ul>

                    <div class="clearboth"></div>
                </div>

            </tabpanel>
            <!-- END Account Statement -->

            <!-- Dispatch Details  -->

             <tabpanel id="filterLayout2" if="${sessionScope.isCustomer}">
                <div class="replace_border" >
                    <div class="marg-bottom25" apply="org.zkoss.bind.BindComposer"
                        viewModel="@id('vm') @init('org.novelerp.controller.DispatchDetailsController')">
                        <grid emptyMessage="No Records Found" model="@bind(vm.dispatchDetails)">
                            <columns sizable="true">
                                 <column align="center" width="190px">Document No</column>
                                 <column align="center" width="180px">Document Type</column>
                                 <column align="center" width="180px">Dispatched Date</column>
                                 <column align="center" width="190px">AWB</column>
                                 <column align="center" width="193px">COURIER</column>
                                 <column align="center" width="180px">Delivery Date</column>
                            </columns>
                            <rows>
                                <template name="model">
                                    <row>
                                        <label value="@load(each.documentno)" />
                                        <label value="@load(each.documenttype)" />
                                        <label value="@load(each.dispatchdate)" />
                                        <label value="@load(each.awb)" />
                                        <label value="@load(each.courier)" />
                                        <label value="@load(each.delivery)"/>
                                    </row>
                                </template>

                            </rows>
                        </grid>         
                    </div>
                </div>
                <div class="clearboth"></div>
            </tabpanel> 

        <!-- END Dispatch Details  -->


           <!-- Refer a Friend -->

            <tabpanel id="refer" if="${sessionScope.isCustomer}" apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('org.novelerp.controller.ReferFriendController')">
                <div sclass="query_form refer_friend padd15">
                    <h:ul>
                        <h:li>
                            <h:span>Referral Name <h:strong style="color:red;">* </h:strong></h:span>
                            <textbox id="receiver_name" value="@bind(vm.refer.referalname)"></textbox>
                        </h:li>
                        <h:li>
                            <h:span>Referral Email-id <h:strong style="color:red;">* </h:strong></h:span>
                            <textbox id="r_emailID" value="@bind(vm.refer.referalemail)" constraint="/^$|\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/: Please enter an e-mail address"/>
                        </h:li>
                        <h:li>
                            <h:span>Mobile Number <h:strong style="color:red;">* </h:strong></h:span>
                            <listbox mold="select" model="@load(vm.mcode)" selectedItem="@bind(vm.code)" width="95px" onSelect="@command('onCode')">
                                <template name="model">
                                    <listitem label="@load(each.ccodename)" value="@load(each.code)"></listitem>
                                </template>
                            </listbox>
                            <!-- <textbox id="contactID" width="98px" value="@bind(vm.refer.contactnumber)" constraint="/^$|[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/:Please enter 10 digits only"/> -->
                            <textbox id="contactID" width="98px" value="@bind(vm.refer.contactnumber)" constraint="@bind(vm.ctt)"/><!-- constraint="${constraint}" -->
                        </h:li>
                        <h:li>
                            <h:span>City<h:strong style="color:red;">* </h:strong></h:span>
                            <listbox id="city" mold="select" model="@load(vm.citylist)" selectedItem="@bind(vm.refer.pcity)" onSelect="@command('onCitySelect')">
                            <template name="model">
                                <listitem value="@load(each.id)" label="@load(each.city)"></listitem>
                            </template>
                            </listbox>
                        </h:li>
                        <h:li>
                            <h:span>Project Type<h:strong style="color:red;">* </h:strong></h:span>
                            <listbox id="projecttype" mold="select" model="@load(vm.projectTypes)" selectedItem="@bind(vm.refer.projecttypet)" onSelect="@command('onProjectTypeSelect')">
                            <template name="model">
                                <listitem value="@load(each.value)" label="@load(each.typename)"></listitem>
                            </template>
                            </listbox>
                        </h:li>
                        <h:li>
                            <h:span>Project Name<h:strong style="color:red;">* </h:strong></h:span>
                            <listbox id="projectname" model="@load(vm.projectNames)" mold="select" selectedItem="@bind(vm.refer.projectnamel)" onSelect="@command('onProjectSelect')">
                                <template name="model">
                                    <listitem label="@load(each.projectname)" value="@load(each.projectsfdccode)"></listitem>
                                </template> 
                            </listbox>
                        </h:li>
                        <h:li>
                            <h:span>Send me a copy</h:span>
                            <checkbox id="sendcopy" checked="@bind(vm.refer.sendcopy)"/>
                        </h:li>
                    </h:ul>
                    <div class="clearboth"></div>
                    <grid visible="@load(vm.forms)" 
                            model="@load(vm.referlist) @template((vm.displayEdit and each.editingStatus) ? 'editable' : 'noneditable')" 
                                sizedByContent="true" span="true" emptyMessage="No Records Found." id="referinline">
                        <columns>
                            <column label="Referral Name"></column>
                            <column label="Referral Email-id"></column>
                            <column label="Contact Number"></column>
                            <column label="Project Type"></column>
                            <column label="Project Name"></column>
                            <column label="Edit" visible="@load(vm.displayEdit)"></column>
                            <column label="Delete"></column>
                        </columns>
                        <template name="editable">
                            <row>
                                <textbox value="@load(each.referalname)  @save(each.referalname, before='confirm')" rows="1" hflex="1"/>
                                <textbox value="@load(each.referalemail)  @save(each.referalemail, before='confirm')" rows="1" hflex="1" constraint="/.+@.+\.[a-z]+/: Please enter an e-mail address"/>
                                <textbox value="@load(each.contactnumber)  @save(each.contactnumber, before='confirm')" rows="1" hflex="1"/>
                                <listbox  model="@load(vm.projectTypes)"  mold="select" onSelect="@command('onProjectTypeSelect')"  selectedItem="@bind(vm.refer.projecttypet)">
                                    <template name="model">
                                        <listitem label="@load(each.typename)" value="@load(each.typename)"></listitem>
                                    </template>
                                </listbox>
                                <div>
                                    <button
                                        image="/css/images/tick-small.png"
                                        onClick="@command('confirm', ReferFriend=each)" />  
                                    <button
                                        image="/css/images/cross-small.png"
                                        onClick="@command('changeEditableStatus', ReferFriend=each)" />
                                </div>
                                <button image="/css/images/cross-small.png"
                                    onClick="@command('onDelete', ReferFriend=each )" />
                            </row>
                        </template>

                        <template name="noneditable">
                            <row>
                                <label value="@load(each.referalname)"></label>
                                <label value="@load(each.referalemail)"></label>
                                <label value="@load(each.contactnumber)"></label>
                                <label value="@load(each.projecttypet.value)"></label>
                                <label value="@load(each.projectnamel.projectname)"></label>
                                <button image="/css/images/pencil-small.png" 
                                    onClick="@command('changeEditableStatus', ReferFriend=each)" />
                                <button image="/css/images/cross-small.png"
                                    onClick="@command('onDelete', ReferFriend=each )" />    
                            </row>
                        </template>
                    </grid> 
                    <div>
                        <button type="submit" class="button" style="margin-top: 5px;" onClick="@command('submit')" id="refer_form_submit">Submit</button>
                    </div>  
                </div>
                <div>
                    <grid id="displayref" visible="true" model="@load(vm.gridLists)" sizedByContent="true" 
                        span="true" emptyMessage="No Records Found." height="250px">
                        <columns sizable="true">
                             <column align="center" width="140px">Referal Name</column>
                             <column align="center" width="215px">Referral Email-id</column>
                             <column align="center" width="120px">Contact Number </column>
                             <column align="center" width="135px">Project Type</column>
                             <column align="center" width="120px">Project Name</column>
                             <column align="center" width="120px">Send me a copy</column>
                        </columns>
                        <template name="model">
                                <row popup="detail_${each.referID}, position=end_before" style="cursor:pointer">
                                    <label value="@load(each.referalname)" />
                                    <label value="@load(each.referalemail)" />
                                    <label value="@load(each.contactnumber)" />
                                    <label value="@load(each.projecttype)" />
                                    <label value="@load(each.projectname)" />

                                    <label value="@load(each.sendmeacopy)"/>
                                </row>
                        </template>
                    </grid>

                </div>
            </tabpanel>


            <tabpanel id="bplanpanel" if="${sessionScope.isCustomer}" apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('org.novelerp.controller.DashboardUIController')">
                <grid model="@bind(vm.billingPlansList2)" >
                    <columns sizable="true">
                        <column label="Billing Date"></column>
                        <column label="Date Description"></column>
                        <column label="MileStone Relavance"></column>
                        <column label="Block"></column>
                        <column label="Billing Status"></column>
                    </columns>
                    <template name="model">
                        <row>
                            <label value="@bind(each.billingdate)"></label>
                            <label value="@bind(each.datedescription)"></label>
                            <label value="@bind(each.milestonerelavance)"></label>
                            <label value="@bind(each.billingblock)"></label>
                            <label value="@bind(each.billingstatus)"></label>
                        </row>
                    </template>
                </grid>
            </tabpanel>
        </tabpanels>

    </tabbox>
</window>

</zk>

This Is My Controller package org.novelerp.controller;

import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.InputStream; import java.math.BigDecimal; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.text.ParseException; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Properties;

import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession;

import net.sf.jasperreports.engine.JRExporter; import net.sf.jasperreports.engine.JRExporterParameter; import net.sf.jasperreports.engine.JasperFillManager; import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JasperReport; import net.sf.jasperreports.engine.util.JRLoader;

import org.compiere.model.MCredentials; import org.compiere.model.MCustomerFeedback; import org.compiere.model.MImage; import org.compiere.model.MPortalUsage; import org.compiere.model.MUpdateProfile; import org.compiere.model.MUploadGallerySHeader; import org.compiere.model.MUser; import org.compiere.model.Query; import org.compiere.util.DB; import org.compiere.util.Env; import org.novelerp.component.SortControl; import org.novelerp.dataaccess.NVCustomerDaoImpl; import org.novelerp.filter.FaqFilter; import org.novelerp.model.BillingPlan; import org.novelerp.model.CRCAdmin; import org.novelerp.model.Country; import org.novelerp.model.CountryCode; import org.novelerp.model.Customer; import org.novelerp.model.CustomerFeedback; import org.novelerp.model.Faq; import org.novelerp.model.Flat; import org.novelerp.model.FlatCode; import org.novelerp.model.FlatCodeDisplay; import org.novelerp.model.ImageModel; import org.novelerp.model.Month; import org.novelerp.model.MyProfileDisplay; import org.novelerp.model.Myprofile; import org.novelerp.model.PaymentDetails; import org.novelerp.model.PaymentOpening; import org.novelerp.model.PaymentSummary; import org.novelerp.model.PortalUsage; import org.novelerp.model.ProjectName; import org.novelerp.model.ProjectOverview; import org.novelerp.model.SessionSet; import org.novelerp.model.TelephoneCountry; import org.novelerp.model.TowerName; import org.novelerp.model.Year; import org.novelerp.services.BillingPlanService; import org.novelerp.services.BillingPlanServiceImpl; import org.novelerp.services.CRCServiceImpl; import org.novelerp.services.CountryCodeServiceImpl; import org.novelerp.services.CustomerService; import org.novelerp.services.CustomerServiceImpl; import org.novelerp.services.FaqService; import org.novelerp.services.FaqServiceImpl; import org.novelerp.services.FeedbackServiceImpl; import org.novelerp.services.FlatCodeServiceImpl; import org.novelerp.services.FlatDisplayService; import org.novelerp.services.FlatDisplayServiceImpl; import org.novelerp.services.FlatServices; import org.novelerp.services.FlatServicesImpl; import org.novelerp.services.MyProfileServiceImpl; import org.novelerp.services.MyProfileServices; import org.novelerp.services.PaymentDetailsServicesImpl; import org.novelerp.services.PaymentSummaryServices; import org.novelerp.services.PaymentSummaryServicesImpl; import org.novelerp.services.PortalUsageServiceImpl; import org.novelerp.services.ProjectNameService; import org.novelerp.services.ProjectNameServiceImpl; import org.novelerp.services.ProjectOverviewService; import org.novelerp.services.ProjectOverviewServiceImpl; import org.zkoss.bind.BindUtils; import org.zkoss.bind.annotation.BindingParam; import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.ContextParam; import org.zkoss.bind.annotation.ContextType; import org.zkoss.bind.annotation.ExecutionParam; import org.zkoss.bind.annotation.GlobalCommand; import org.zkoss.bind.annotation.Init; import org.zkoss.bind.annotation.NotifyChange; import org.zkoss.exporter.excel.ExcelExporter; import org.zkoss.util.media.AMedia; import org.zkoss.zhtml.Li; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.Sessions; import org.zkoss.zk.ui.WrongValueException; import org.zkoss.zk.ui.event.UploadEvent; import org.zkoss.zk.ui.select.SelectorComposer; import org.zkoss.zk.ui.select.annotation.Listen; import org.zkoss.zk.ui.select.annotation.Wire; import org.zkoss.zk.ui.util.Clients; import org.zkoss.zul.A; import org.zkoss.zul.Button; import org.zkoss.zul.Checkbox; import org.zkoss.zul.Column; import org.zkoss.zul.Columns; import org.zkoss.zul.Constraint; import org.zkoss.zul.Datebox; import org.zkoss.zul.Div; import org.zkoss.zul.Filedownload; import org.zkoss.zul.Grid; import org.zkoss.zul.Image; import org.zkoss.zul.Label; import org.zkoss.zul.Listbox; import org.zkoss.zul.Listitem; import org.zkoss.zul.Messagebox; import org.zkoss.zul.Radio; import org.zkoss.zul.Radiogroup; import org.zkoss.zul.Row; import org.zkoss.zul.Rows; import org.zkoss.zul.Span; import org.zkoss.zul.Tab; import org.zkoss.zul.Tabbox; import org.zkoss.zul.Tabpanel; import org.zkoss.zul.Textbox; import org.zkoss.zul.Window;

public class DashboardUIController extends SelectorComposer<component>{

public DashboardUIController() {
    super();
    Myprofile profile=(Myprofile)Sessions.getCurrent().getAttribute("myprofile");
    if(profile != null)
    {

// System.out.println("profile.getAddress():-"+profile.getAddress()); test = profile.getAddress(); }

}

private static final long serialVersionUID = 1L;

@Wire("#grid")
Grid grid;

@Wire
Datebox fromDate1,toDate1,fromDate3,toDate3,dateofbirth,weeding;

@Wire
Datebox fromDate2,toDate2;

@Wire
Window main,gallerypopup,updatewindow;

@Wire
Label project,asset,accountname,asset1,contactname,mobnumber,smobnumber,lbl1,billdate,bplan;

@Wire
Listitem complaint,feedback,enquire,request1,modification,snag;

@Wire
Li heading1;

@Wire
Tab tabmyprofile,tabproject,tabkowledge,tabgalery,tabconstruction,tabupload,tabusage,tabfaq,tabbplan,tabaccount,tabdispatch,tabflat,tabcontact,tabrefer,tabwrite,tabprogress,tabrequest,tabresopns;

@Wire 
Listbox productGroup,subtype1,subtype2,subtype3,subtype4,subtype5,typegroup,subtype,codetype,codetype1;

@Wire
Radio present,perminet;

@Wire
Radiogroup nature,preferdaddress;

@Wire
Textbox faqprojectname,permanent,adminsearch,adminsearch1,description,receiver_name,r_emailID,mobileno,telephone,presentadd,preferedadd,emailid,others,receiver_name1,r_emailID1,contactID1,contactID,subject,addre1,addr2,area,city,pincode,state,country;
/*@Wire
Row upload,upload1;*/

/*@Wire
Datebox dateofbirth,weeding;*/

@Wire
Label faqproject1,faqtowername,faqtopic,faqquestion,faqreply,faqupdate,birthdate,perminentaddress,presentaddress,postalcode,state1,email,telno,mobileno1,projectsummary,flatcodesummary,ccodesummary,totalsummary,paidsummary,balancesummary,tollfree,hocontact,regioncontact,headoffice,siteoffice,regional,name,firstname,custcode,bookingid,projectname1,allatment,flatno,flattype,agreement,consideration,wing,pcode,description1;

@Wire
A url;

@Wire
Image project_logo,imageicon;


@Wire
Checkbox sendcopy,sendcopy1;

@Wire
Div video,pamentDetail,filterLayout,filter,addnew,terms,upload1,upload,faqsearch;

@Wire("#paymentDetailGrid")
Grid paymentDetails,paymentDetailGrid;

@Wire
Grid dispatchDetailGrid,referinline,displayref,usageGrid;

@Wire
Tabbox customerLayout,tabbox;

@Wire
Button searchShip,search,search1,searchShip2,image2,editprofile,submit,cancel,addmore,beforesubmit,aftersubmit,export_pdf,export_exel,fileupload,export_print;

@Wire
Tabpanel customerDetails,projectview,gallery,galleryconstruction,filterLayout1,filterLayout2,flatcollapse,knowledgepannel,contactus,galupload,usage,faqpanel,refer,writeto,feedbackcol,feedbackresponse,trackprogress,bplanpanel;

@Wire
Span mobilespn,preferedspan,presentspan,heading;

Tab lastTab;

CountryCode code = new CountryCode();
TelephoneCountry tcode = new TelephoneCountry();
Myprofile profile = new Myprofile();

/*Added by shrikant*/
String slctdYear = "";
List<Month> months = new LinkedList<Month>();
List<Year> years = new LinkedList<Year>();
List<ImageModel> imgList = new LinkedList<ImageModel>();
HttpServletRequest request;
private static final String IMAGE_PATH = "E:\\websites\\gplcrmnew\\NovelERP\\";

// private static final String IMAGE_PATH = "d:\"; /* "E:\websites\gplcrmnew\NovelERP\" * "c:\"*/

List<CountryCode> mcode = new CountryCodeServiceImpl().getCountryCodesList("",code);
List<TelephoneCountry> telcode = new CountryCodeServiceImpl().getCountryCodesList1("",tcode);
List<ProjectName> projectNames = new ProjectNameServiceImpl().getProjectNamesList("");
Customer customer;
CustomerService customerService;
BillingPlanService billingService;
FlatServices flatsummary;
ProjectOverviewService projectoverview;
Flat flat;
ProjectOverview overview1;
PaymentSummary summary;
PaymentSummaryServices payservice;
Myprofile myprofilecrc;
MyProfileServices profileservice;
List<Faq> faq;
List<BillingPlan> plan;
FaqService faqservice;

List<BillingPlan> bPlanList = new ArrayList<BillingPlan>();

//List<TowerName> towerName = new TowerNameServiceImpl().getTowerNamesList("");
//List<FlatCode> fList = new FlatCodeServiceImpl().getFlatcodeKunnr("");
//List<FlatCodeDisplay> flatcodelist = new FlatDisplayServiceImpl().getFlatCodes("");
//List<ProjectName> projectNames = new ArrayList<ProjectName>();
List<BillingPlan> billingPlansList2 = new ArrayList<BillingPlan>();// new BillingPlanServiceImpl().getBillinPlanList("");

List<FlatCodeDisplay> flatcodeDisplay = new ArrayList<FlatCodeDisplay>();
List<TowerName> towerDisplayList = new ArrayList<TowerName>();
public List<TowerName> getTowerDisplayList() {
    return towerDisplayList;
}
public void setTowerDisplayList(List<TowerName> towerDisplayList) {
    this.towerDisplayList = towerDisplayList;
}
public List<FlatCodeDisplay> getFlatcodeDisplay() {
    return flatcodeDisplay;
}
public void setFlatcodeDisplay(List<FlatCodeDisplay> flatcodeDisplay) {
    this.flatcodeDisplay = flatcodeDisplay;
}

TowerName tname = new TowerName();
ProjectName pname = new ProjectName();
FlatCodeDisplay fcode = new FlatCodeDisplay();

List<FlatCodeDisplay> flatCode = new ArrayList<FlatCodeDisplay>();
//ProjectNa projectNames = new ArrayList<ProjectName>();
//21-07-2014 added 
ProjectNameService projectservice = new ProjectNameServiceImpl();
FlatDisplayService flatservice = new FlatDisplayServiceImpl();

@Command
@NotifyChange({"projectNames","towerName","flatcodelist","towerDisplayList"})
public void onProjectSelect()
{

    System.out.println("Enter To Project Select:::--215:-"+pname.getProjectcode());
    towerDisplayList = projectservice.getProjectNameTowerList(" pr.vkorg = '"+pname.getProjectcode().toString()+"' order by 1 ");
    pname.setTowername(towerDisplayList.get(0));
    //tname.set(towerName.get(0));
    Sessions.getCurrent().setAttribute("projectcode", pname.getProjectcode());
}

@Command
@NotifyChange({"flatcodeDisplay"})
public void onTowerSelect()
{
    System.out.println("Enter To Project Select:::::-222:-"+tname.getTowercode());
    flatcodeDisplay = flatservice.getFlatCodes(" and vbak.vkorg ='"+pname.getProjectcode()+"' and too1w.werks = '"+tname.getTowercode()+"'");
    tname.setFltcode(flatcodeDisplay.get(0));
    System.out.println("flatcodelist.get(0):-"+flatcodeDisplay.get(0));
    System.out.println("fcode:-249:-"+fcode.getFlatcode());
    /*fList = flatservice.getFlatcodeKunnr(" and vbak.vkorg ='"+pname.getProjectcode()+"' and too1w.werks = '"+tname.getTowercode()+"'");*/
    //tname.setFltcode(fList.get(0));
    Sessions.getCurrent().setAttribute("towercode", tname.getTowercode());
}
String fltcode = "";
@Command
public void onCustomerSelect(@BindingParam("ref") Listitem selected)
{
    fltcode = selected.getValue();
    System.out.println("fltcode:--283:-"+fltcode);
    Sessions.getCurrent().setAttribute("fltcode", fltcode);

}

@Listen("onClick=#finddetails")
public void findDetails()
{
    String flatcode = Sessions.getCurrent().getAttribute("fltcode").toString();
    String Towercode = Sessions.getCurrent().getAttribute("towercode").toString();
    String ProjectCode = Sessions.getCurrent().getAttribute("projectcode").toString();
    /*if(flatcode!=null && Towercode != null && ProjectCode != null)
    {*/
        System.out.println("Enter To search...............444"+flatcode);
        //filter.setVisible(true);
        //beforesubmit.setVisible(false);
        aftersubmit.setVisible(false);
        //filter.setVisible(true);
        export_pdf.setVisible(true);
        export_exel.setVisible(true);
        paymentDetailGrid.setVisible(true);
        terms.setVisible(true);
        saveusage("report_statmentofaccount");
        //export_print.setVisible(true);
        createPaymentDetails(flatcode,fromDate1,toDate1);
        System.out.println("fcode.getCustomercode():-"+fcode.getCustomercode());
    /*}
    else
    {
        Messagebox.show("Please select Mandatory Fields", "Dashboard", Messagebox.OK, Messagebox.ERROR);
    }*/

}

public FlatCodeDisplay getFcode() {
    return fcode;
}

public void setFcode(FlatCodeDisplay fcode) {
    this.fcode = fcode;
}

public List<FlatCodeDisplay> getFlatCode() {
    return flatCode;
}

public void setFlatCode(List<FlatCodeDisplay> flatCode) {
    this.flatCode = flatCode;
}

public TowerName getTname() {
    return tname;
}

public void setTname(TowerName tname) {
    this.tname = tname;
}


public ProjectName getPname() {
    return pname;
}

public void setPname(ProjectName pname) {
    this.pname = pname;
}

public List<ImageModel> getImgList() {
    return imgList;
}

public void setImgList(List<ImageModel> imgList) {
    this.imgList = imgList;
}

public List<Month> getMonths() {
    return months;
}

public void setMonths(List<Month> months) {
    this.months = months;
}

public List<Year> getYears() {
    return years;
}

public void setYears(List<Year> years) {
    this.years = years;
}
public String getSlctdYear() {
    return slctdYear;
}

public void setSlctdYear(String slctdYear) {
    this.slctdYear = slctdYear;
}

public void setTcode(TelephoneCountry tcode) {
    this.tcode = tcode;
}

public TelephoneCountry getTcode() {
    return tcode;
}

public void setProfile(Myprofile profile) {
    this.profile = profile;
}

public Myprofile getProfile() {
    return profile;
}

public CountryCode getCode() {
    return code;
}
public void setCode(CountryCode code) {
    this.code = code;
}


public List<TelephoneCountry> getTelcode() {
    return telcode;
}

public List<CountryCode> getMcode() {
    return mcode;
}

 String CustomerCode = Sessions.getCurrent().getAttribute("CustomerCode").toString();
//Start Listbox filter
@Listen("onClick=#complaint")
public void complaint()
{
    System.out.println("Enter Complaint.....");
    subtype.setVisible(true);
    subtype1.setVisible(false);
    subtype2.setVisible(false);
    subtype3.setVisible(false);
    heading.setVisible(true);
}

@Listen("onClick=#feedback")
public void feedback()
{
    System.out.println("Enter FeedBack.....");
    subtype.setVisible(false);
    subtype1.setVisible(true);
    subtype2.setVisible(false);
    subtype3.setVisible(false);
    heading.setVisible(true);
}

@Listen("onClick=#enquire")
public void enquire()
{
    subtype.setVisible(false);
    subtype1.setVisible(false);
    subtype2.setVisible(true);
    subtype3.setVisible(false);
    heading.setVisible(true);
}

@Listen("onClick=#request1")
public void request()
{
    subtype.setVisible(false);
    subtype1.setVisible(false);
    subtype2.setVisible(false);
    subtype3.setVisible(true);
    heading.setVisible(true);
}

@Listen("onClick=#modification")
public void modification()
{
    subtype.setVisible(false);
    //subtype.setName("");
    subtype1.setVisible(false);
    subtype2.setVisible(false);
    subtype3.setVisible(false);
    heading.setVisible(false);
    //heading1.setVisible(false);
}

@Listen("onClick=#snag")
public void snag()
{
    subtype.setVisible(false);
    subtype1.setVisible(false);
    subtype2.setVisible(false);
    subtype3.setVisible(false);
    heading.setVisible(false);
    //heading1.setVisible(false);
}

//END Listbox filter

//tabbox click on open and close
@Command
public void alternate(@BindingParam("tab") Tab tab, @BindingParam("tabbox") Tabbox tabbox) {
    if (lastTab==null) {
        lastTab = tabbox.getSelectedTab();
    }
    if (tabbox.getSelectedTab().equals(lastTab)) {
        try {
            tabbox.setSelectedIndex(tabbox.getSelectedIndex() + 1);
        } catch (Exception e) {
            tabbox.setSelectedIndex(0);
        }
    } else {
        tabbox.setSelectedTab(tab);
    }
    lastTab = tabbox.getSelectedTab();
}

// mouse over side pannel collapse
/*@Command
public void addEventListener(final @BindingParam("splitter") Splitter splitter) {
    System.out.println("Enter Add Event.........."+splitter);
    splitter.addEventListener(Events.ON_MOUSE_OVER, new EventListener<Event>() {

            public void onEvent(Event event) throws Exception {
                splitter.setOpen(!splitter.isOpen());
                System.out.println("Enter OnEvent..........");

            }
        });
}*/

@Listen("onClick=#video")
public void openVideo(){
    System.out.println("Enter to Video Tutorial:-");
    saveusage("videotutorial");
    Clients.evalJavaScript("MM_openBrWindow('','','width=650,height=550,top=80,left=80,scrollbars=no')");
}

@Listen("onUpload = #image2")
public void upload(UploadEvent event) {
    org.zkoss.util.media.Media media = event.getMedia();

    if (media instanceof org.zkoss.image.Image) {

        org.zkoss.zul.Image image = new org.zkoss.zul.Image();

        image2.setImageContent( (org.zkoss.image.Image) media);
        byte[] uploadImage = media.getByteData();

        System.out.println("Image Bianry Data:-"+media.getByteData());
        Properties ctx = (Properties) Sessions.getCurrent().getAttribute("Portal_Ctx");

// String CustomerCode = Sessions.getCurrent().getAttribute("CustomerCode").toString(); // String NVCustomerID = Sessions.getCurrent().getAttribute("NVCustomerID").toString(); String ADUserID = Sessions.getCurrent().getAttribute("ADUserID").toString(); System.out.println("UIUser:-"+ADUserID); int userid = Integer.parseInt(ADUser_ID);

        MUser mUser = new MUser(ctx, user_id, null);
        mUser.get_Value("AD_Image_ID");
        System.out.println("AD_Image_ID:-"+mUser.get_Value("AD_Image_ID"));
        int AD_Image_ID = 0;

        if(mUser.get_Value("AD_Image_ID")!=null)
        {
            AD_Image_ID = (Integer)(mUser.get_Value("AD_Image_ID"));
        }

        MImage mImage = new MImage(ctx, AD_Image_ID, null);

        mImage.setBinaryData(uploadImage);
        mImage.setName(AD_User_ID+media.getName());
        mImage.setEntityType("D");
        mImage.save();
        mUser.set_ValueOfColumn("AD_Image_ID",mImage.getAD_Image_ID());
        System.out.println("New ImageID:-"+mImage.getAD_Image_ID());
        mUser.save();

    } else {
        Messagebox.show("Not an image: "+media, "Error", Messagebox.OK, Messagebox.ERROR);
    }
}

@Listen("onClick=#export_pdf")
public void exportGrid() throws Exception {
    System.out.println("Eneter PdfReport");
    String openReport = (String) Sessions.getCurrent().getAttribute("openReport");
    MCredentials crd = new Query(Env.getCtx(), MCredentials.Table_Name, "", null).setOnlyActiveRecords(true).first();

    System.out.println("Report open :- - "+openReport);
    ByteArrayOutputStream bytesOutputStream = new ByteArrayOutputStream();
    BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(bytesOutputStream);
    /*JasperReport  jasperReport = (JasperReport) JRLoader.loadObject("C:\\NovelERP\\reports\\"+openReport+".jasper");*/
    /*JasperReport  jasperReport = (JasperReport) JRLoader.loadObject("C:"+File.separator+File.separator+"NovelERP"+File.separator+File.separator+"reports"+File.separator+File.separator+openReport+".jasper");*/
    JasperReport  jasperReport = (JasperReport) JRLoader.loadObject(crd.getReportPath()+openReport+".jasper");
    /*JasperReport  jasperReport = (JasperReport) JRLoader.loadObject("E:\\websites\\gplcrmnew\\NovelERP\\reports\\"+openReport+".jasper");*/



    System.out.println("Enter In To Jasper1"+jasperReport);
    Map params=new HashMap();

    Connection connection= DB.getConnectionRW();


        PreparedStatement pstmt = null,pstmt2=null,pstmt3=null;
        ResultSet rs = null,rs2=null,rs3=null;
        Date DateFrom,DateTo;

        try{
            String sql = "select nv_customer_id,customercode from nv_customer where customercode = '"+CustomerCode+"'";
            pstmt = DB.prepareStatement(sql, null);
            rs=pstmt.executeQuery();
            rs.next();

            params.put("NV_Customer_ID", rs.getString("customercode"));
        }
        catch(SQLException e){
            e.printStackTrace();
        }
        finally{
            DB.close(rs, pstmt);
        }

        String session = Sessions.getCurrent().getAttribute("reportsession").toString();
        System.out.println("session408:-"+session);
        try
        {
            String sessionquery = "select sessionid,customercode from t_statement_temp where customercode= '"+CustomerCode+"'" +
                                " and sessionid='"+session+"'";

            System.out.println("session query:----"+sessionquery);
            pstmt3 = DB.prepareStatement(sessionquery, null);
            rs3=pstmt3.executeQuery();
            rs3.next();

            params.put("Session_ID", rs3.getString("sessionid"));
        }
        catch(SQLException e1)
        {
            e1.printStackTrace();
        }
        finally{
            DB.close(rs2, pstmt2);
        }

        //for projectcode
        try
        {
            String projectcode = " Select distinct vbak.vkorg as projectcode from nv_vbpa_sap vbpa " +
                                    " INNER JOIN nv_vbak_sap vbak ON (vbpa.vbeln=vbak.vbeln)" +
                                    " INNER JOIN nv_vbap_sap vbap ON (vbak.vbeln = vbap.vbeln)" +
                                    " WHERE vbpa.kunnr='"+CustomerCode+"' AND vbpa.parvw='RG' AND vbap.posnr=10 AND vbak.AUART IN ('ZG01','ZG03','ZG04') ";

            System.out.println("Running qury:----"+projectcode);
            pstmt2 = DB.prepareStatement(projectcode, null);
            rs2=pstmt2.executeQuery();
            rs2.next();
            System.out.println("project Code:-"+rs2.getString("projectcode"));
            params.put("projectcode", rs2.getString("projectcode"));
        }
        catch(SQLException e1)
        {
            e1.printStackTrace();
        }
        finally{
            DB.close(rs2, pstmt2);
        }

        DateFrom = fromDate1.getValue();
        DateTo = toDate1.getValue();
        System.out.println("Date from -------- "+DateFrom +"lskmdflkmfd "+ DateTo);
        params.put("DateFrom", DateFrom);
        params.put("DateTo", DateTo);

        if(fromDate1.getValue()!=null && toDate1.getValue()!=null)
        {
            System.out.println("Enter Report Fields:-");
            DateFrom = fromDate1.getValue();
            System.out.println("DateFrom3333:-"+DateFrom);
            DateTo = toDate1.getValue();
            System.out.println("DateTo33333:-"+DateTo);
            params.put("DateFrom", DateFrom);
            params.put("DateTo", DateTo);
            System.out.println("1111111111111"+params.get("DateFrom"));
            System.out.println("222222222222"+params.get("DateTo"));
        }else
            if(fromDate1.getValue()!=null)
            {
                System.out.println("Enter Report Fields2222:-");
                DateFrom = fromDate1.getValue();
                params.put("DateFrom",DateFrom);
            }
            else
                if(toDate1.getValue()!=null)
                {
                    System.out.println("Enter Report Fields222233333:-");
                    DateTo = toDate1.getValue();
                    params.put("DateTo",DateTo);
                }
    HttpSession  httpsession = (HttpSession)(Executions.getCurrent()).getDesktop().getSession().getNativeSession();
    String sessionID = httpsession.getId()+Sessions.getCurrent().getAttribute("ReportTime");


     JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, connection);
      System.out.println("Enter In To Jasper");
        //Jasperreport jasperPrint =new Jasperreport("/home/user/Desktop/Godrej/godrejportal_new/26 SEPT/Financial Summary Report.jrxml");
        JRExporter exporter = new net.sf.jasperreports.engine.export.JRPdfExporter();
        exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
        exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, bufferedOutputStream);
        exporter.exportReport();
         System.out.println("Enter In To Jasper4444");
        InputStream mediais = new ByteArrayInputStream(bytesOutputStream.toByteArray());
        System.out.println("mediais jasper:-"+mediais);

        try{
            System.out.println("IPad -- - ");
        AMedia amedia = new AMedia(openReport+".pdf", "pdf", "application/pdf", mediais);
        Filedownload.save(amedia); 
        }catch (Exception e) {
            e.printStackTrace();
        }
        bytesOutputStream.close();
        connection.close();
        bufferedOutputStream.close();
}

@Command
public void exportGridToExcel(@BindingParam("ref") Grid paymentDetailGrid) throws Exception {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
     //System.out.println("Eneter Excel Format:-"+out);
     String openReport = (String) Sessions.getCurrent().getAttribute("openReport");
     //System.out.println("openReport:--"+openReport);
     //System.out.println("paymentDetailGrid:-"+paymentDetailGrid);
    ExcelExporter exporter = new ExcelExporter();
    //System.out.println("exporter:-"+exporter);
    exporter.export(paymentDetailGrid, out);
    //String openReport = (String) Sessions.getCurrent().getAttribute("openReport");

    AMedia amedia = new AMedia(openReport+".xlsx", "xls", "application/file", out.toByteArray());
    Filedownload.save(amedia);
    out.close();
}

/*@Command

public void exportGridToprint(@BindingParam("ref") Grid paymentDetailGrid) throws Exception {
     String openReport = (String) Sessions.getCurrent().getAttribute("openReport");
     System.out.println("Enter Print:-");
     String name = paymentDetailGrid.toString(); 
     PrinterJob printJob = PrinterJob.getPrinterJob();
}*/

@Listen("onClick=#addmore")
public void addMore()
{
    referinline.setVisible(true);
    //addmore.setVisible(false);
}

Myprofile myprofile1;
/*ProjectOverview overview;
 Flat flat;*/

 @Init
 public void init(@ExecutionParam("myprofile") Myprofile myprofile,@ExecutionParam("overview") ProjectOverview overview
         ,@ExecutionParam("flat") Flat flat,@ExecutionParam("customer") Customer customer,@ExecutionParam("summary") PaymentSummary summary
         ,@ExecutionParam("faq") List<Faq> faq,@ExecutionParam("plan") List<BillingPlan> plan){


     request = (HttpServletRequest)Executions.getCurrent().getNativeRequest();

     System.out.println("Calling Init:-"+request.getRealPath(File.separator));
     this.myprofile1 = myprofile;
     this.customer = customer;
     this.flat = flat;
     this.overview1 = overview;
     this.summary = summary;
     this.myprofilecrc = myprofile;
     this.faq = faq;
     this.plan = plan;
     /*this.overview = overview;
     this.flat = flat;*/

     years =  getYearList();

     if(years!=null && years.size()>0)
     {
         for(Year year:years)
         {
             if(year.isSelected())
                 slctdYear=year.getyName();
         }
         /*Year year = years.get(0);
         slctdYear = year.getyName();*/
         System.out.println("in Init slctdYear ... "+slctdYear);
         months = getMonthFolderList();
     }

     if(months!=null && months.size()>0)
        {
            Month month= months.get(0);
            imgList = getImageList(month.getmName());
            System.out.println("in Init month ... "+month.getmName());
        }


     /*Year yr = new Year();
     yr.setyName("2014");
     yr.setyValue("2014");
     yr.setSelected(true);
     years.add(yr);

     yr = new Year();
     yr.setyName("2013");
     yr.setyValue("2013");

     years.add(yr);*/

// Sessions.getCurrent().setAttribute("myprofile", myprofile); // System.out.println("myprofile.getMobilenumber()111:-"+myprofile1.getMobilenumber()); }

 /*
 @Listen("onBlur=#mobileno")
 public void mobile()
 {
     System.out.println("mobileno.getValue():-"+mobileno.getValue());

     if(mobileno.getValue() == null)
     {
        // mobileno.setConstraint("/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/:Please enter 10 digits only");
         mobileno.setDisabled(false);
         mobileno.setErrorMessage(null);
     }

 }*/
 Country test = new Country();
 String NV_Customer_ID = Sessions.getCurrent().getAttribute("NV_Customer_ID").toString();

 MyProfileDisplay mprofile = new MyProfileDisplay();

// List<MyProfileServiceImpl> profilelist = new


public MyProfileDisplay getMprofile() {
    return mprofile;
}

public Country getTest() {
    return test;
}

// @AfterCompose // public ComponentInfo doBeforeCompose(@ExecutionArgParam("address")) { // // TODO Auto-generated method stub // return super.doBeforeCompose(page, parent, compInfo); // }

@SuppressWarnings("unused")
@Command
public void submit(@ContextParam(ContextType.VIEW) Component view) throws ParseException
{

    //init(myprofile);
    Myprofile myprofile1 = (Myprofile) Sessions.getCurrent().getAttribute("myprofile");

    System.out.println("Submit...........");
    //String countrytype = codetype.getSelectedItem().getLabel();
    //System.out.println("codetype.getSelectedItem().getLabel():-"+codetype.getSelectedItem().getLabel());

    String mobilenumber = test.getMobile();
    String pcountrycode = code.getCode();
    String tcountrycode = tcode.getTcode();

    System.out.println("pcountrycode:-"+pcountrycode);
    System.out.println("***************"+tcode.getTcode());
    System.out.println("***************"+tcode.getTcountry());
    System.out.println("***************:-"+tcode.getTcountrycode());
    //System.out.println("pcountrycodetest:-"+codetype.getSelectedItem().getLabel());
    String tCountrycode = test.getTelcode();
    System.out.println("tCountrycode:-"+tCountrycode);
    System.out.println("pcountrycode:-"+test.getPhonecode());
    //System.out.println("tCountrycode test:-"+codetype1.getSelectedItem().getLabel());
    String telephonenumber = test.getTel();
    String email = test.getEmail();
    String area = test.getArea();
    //System.out.println("area:::::::::4344fff:-"+area);
    /*if(area!=null)
        System.out.println("area:::::::::fff:-"+area);*/
    String Address1="",Address2 = "",area1="",city = "",state="",country="",pincode = ""; 
    if(test.getAddres()!=null)
        Address1 = test.getAddres();
    if(test.getAddres1()!=null)
        Address2 = test.getAddres1();
    if(test.getArea()!=null)
        area1 = test.getArea();
    if(test.getCity()!=null)
        city = test.getCity();
    if(test.getPincode()!=null)
        pincode = test.getPincode();
    if(test.getState()!=null)
        state = test.getState();
    if(test.getCountry()!=null)
        country = test.getCountry();

// String CommuAddress = test.getAddres()+" "+test.getAddres1()+" "+area1+" "+test.getCity()+" "+test.getPincode()+" "+test.getState()+" "+test.getCountry(); String CommuAddress = Address1+" "+Address2+" "+area1+" "+city+" "+pincode+" "+state+" "+country;

    System.out.println("CommuAddress:-"+CommuAddress);
    System.out.println("test.getArea():-"+test.getArea());

    String NV_Customer_ID = Sessions.getCurrent().getAttribute("NV_Customer_ID").toString();
    if(NV_Customer_ID==null || NV_Customer_ID.equals("") || NV_Customer_ID.equals(0))
        return;

    if(((mobilenumber!=null) || (email!=null)))
    {
        System.out.println("Enter Update Profile:-");
        MUpdateProfile mProfile = new Query(Env.getCtx(), MUpdateProfile.Table_Name, " NV_Customer_ID = "+NV_Customer_ID, null).setOnlyActiveRecords(true).first();
        System.out.println("mProfile:-"+mProfile);

        boolean showMsg = false;

        if(mProfile==null)
        {
            mProfile = new MUpdateProfile(Env.getCtx(), 0, null);
            showMsg = true;
        }
            if(mProfile.getMobile_No()!=null && !mProfile.getMobile_No().equals(mobilenumber))
                showMsg=true;
            if(mProfile.getTelephone_No() !=null && !mProfile.getTelephone_No().equals(telephonenumber))
                showMsg=true;
            if(mProfile.getEmail_ID()!=null && !mProfile.getEmail_ID().equals(email))   
                showMsg=true;
            if(mProfile.getPresent_Address()!=null && !mProfile.getPresent_Address().equals(CommuAddress))
                showMsg = true;

            if(mProfile.getAddress1()!=null && !mProfile.getAddress1().equals(Address1))
                showMsg = true;

            if(mProfile.getAddress2()!=null && !mProfile.getAddress2().equals(Address2))
                showMsg = true;
            if(mProfile.getPrintAreaType()!=null && !mProfile.getPrintAreaType().equals(area1))
                showMsg = true;
            if(mProfile.getCity()!=null && !mProfile.getCity().equals(city))
                showMsg = true;
            if(mProfile.getPincode()!=null && !mProfile.getPincode().equals(pincode))
                showMsg = true;
            if(mProfile.getState()!=null && !mProfile.getState().equals(state))
                showMsg = true;
            if(mProfile.getCOUNTRY()!=null && !mProfile.getCOUNTRY().equals(country))
                showMsg = true;
            if(mProfile.getCountryCode()!=null && !mProfile.getCountryCode().equals(pcountrycode))
                showMsg = true;
            if(mProfile.getTelephoneCode()!=null && !mProfile.getTelephoneCode().equals(tcountrycode))
                showMsg = true;


        if(showMsg)
        {
            if(("".equals(mobilenumber)) || mobilenumber!=null){
                mProfile.setMobile_No(mobilenumber);
                //mProfile.setCountryCode(pcountrycode);
                System.out.println("mobilenumber:-"+mobilenumber);
            }

            else{
                mProfile.setMobile_No(myprofile1.getMobilenumber());
            }
            if(!(pcountrycode==null || pcountrycode.trim().equals("")))
            {
                mProfile.setCountryCode(pcountrycode);
            }
            else
            {
                mProfile.setCountryCode(test.getPhonecode());
            }

            if(("".equals(telephonenumber)) || telephonenumber != null)
                mProfile.setTelephone_No(telephonenumber);
            else
                mProfile.setTelephone_No(myprofile1.getTelephonenumber());

            if(!(tcountrycode==null || tcountrycode.trim().equals("")))
            {
                mProfile.setTelephoneCode(tcountrycode);
            }
            else
            {
                mProfile.setTelephoneCode(test.getTelcode());
            }
            if("".equals(email) || email!=null ){
                mProfile.setEmail_ID(email);
                /*if( email.trim().equals(""))
                    mProfile.setEmail_ID(email);
                else
                    mProfile.setEmail_ID(myprofile1.getEmail());*/
            }
            else
                mProfile.setEmail_ID(myprofile1.getEmail());

            if(!(CommuAddress!=null && CommuAddress.trim().equals("")))
            {
                mProfile.setPresent_Address(CommuAddress);

                mProfile.setAddress1(test.getAddres());
                mProfile.setAddress2(test.getAddres1());
                if(test.getArea()!=null)
                    mProfile.setPrintAreaType(test.getArea());
                mProfile.setCity(test.getCity());
                mProfile.setPincode(test.getPincode());
                mProfile.setState(test.getState());
                mProfile.setCOUNTRY(test.getCountry());

                System.out.println("CommuAddress:-"+CommuAddress);
            }
            else
            {
                mProfile.setPresent_Address(myprofile1.getPresentaddress());
                //mProfile.setPrintAreaType(myprofile1.getArea());
            }

            System.out.println("myprofile1.getPresentaddress():-"+myprofile1.getPresentaddress());

        /*if(dob!=null)
        {
            mProfile.setDOB(new Timestamp(dob.getTime()));
        }
        else
        {
            System.out.println("Timestamp :::: "+ myprofile1.getBirthdateT());
            mProfile.setDOB(Timestamp.valueOf(myprofile1.getBirthdateT()));

        }*/

    // Timestamp name4 = Timestamp.valueOf(myprofile1.getWeedinganniversary());
        /*if(wedding!=null)
        {
            mProfile.setWedding_Anni(new Timestamp(wedding.getTime()));
        }
        else
        {
            System.out.println("Timestamp :::: "+ myprofile1.getWeedinganniversaryT());
            if(myprofile1.getWeedinganniversaryT()!=null)
                mProfile.setWedding_Anni(Timestamp.valueOf(myprofile1.getWeedinganniversaryT()));
        }*/


                mProfile.setNV_Customer_ID(Integer.parseInt(NV_Customer_ID));
                showMsg = mProfile.save();
            }


            if(showMsg)//(mProfile.save())
            {

                Messagebox.show("Request to update information successfully submitted \n \n Disclaimer \n \n *Kindly note that changes will be updated in our records within 2 working days. For urgent request, please contact customer care team.", "Edit My Profile", Messagebox.OK,Messagebox.EXCLAMATION);
                try{

                    SfdcAccountUpdate account = new SfdcAccountUpdate(CustomerCode,test.getAddres(),test.getAddres1(),test.getArea(),test.getCity(),test.getPincode(),test.getState(),test.getCountry(),test.getMobile());
                    account.accountUpdate(true);
                }catch (Exception e) {
                    // TODO: handle exception
                    e.printStackTrace();
                }

                Executions.sendRedirect("/dashboard.htm");
            }

            //updatewindow.detach();
            view.detach();
    }

    else 
    {
        Messagebox.show("Please fill Details", "Edit My Profile", Messagebox.OK, Messagebox.ERROR);
    }

}



// End Tabpanel click close



@Command
public void cancel(@ContextParam(ContextType.VIEW) Component view)
{

    view.detach();
}

List<CustomerFeedback> gridLists = new FeedbackServiceImpl().getCustomerFeedbackList("");
public List<CustomerFeedback> getGridLists() {
    //System.out.println("Grid List:-"+gridLists);
    return gridLists;
}

//Customer Create Request
@NotifyChange("gridLists")
@Listen("onClick=#submitWTS")
public void createServiceRequest()
{
    System.out.println("Enter Create Service Request");

// CustomerFeedback feedback = new CustomerFeedback(); //System.out.println("Grid List222:-"+gridLists); String Type = ""; if(typegroup.getSelectedItem()!=null) { Type = typegroup.getSelectedItem().getLabel(); System.out.println("Type:-"+Type); }

    String Subject = subject.getText();
    System.out.println("Subject :-"+Subject);
    String AccountName = accountname.getValue();
    System.out.println("accountname.getValue():-"+AccountName);
    String Asset = asset1.getValue();
    System.out.println("asset1.getValue():-"+Asset);
    String Project = project.getValue();
    System.out.println("project.getValue():-"+Project);
    String Description = description.getText();

    String NV_Customer_ID = Sessions.getCurrent().getAttribute("NV_Customer_ID").toString();
    String CustomerCode = Sessions.getCurrent().getAttribute("CustomerCode").toString();


    MCustomerFeedback mfeedback = new MCustomerFeedback(Env.getCtx(), 0, null);

    if((Type!=null && Type.length() > 0)
            && (Subject!=null && Subject.length() > 0)  
            && (Description!=null && Description.length() > 0)
            )
    {
        mfeedback.setTypeOfResponse(Type);
        mfeedback.setNV_Customer_ID(Integer.parseInt(NV_Customer_ID));
        mfeedback.setCustomerCode(CustomerCode);
        mfeedback.setSubject(Subject);
        mfeedback.setAsset(Asset);
        mfeedback.setAccountName(AccountName);
        mfeedback.setDescription(Description);

        //mfeedback.setContactName(ContactName);
        mfeedback.setProjectName(Project);

        if(mfeedback.save())
        {
            Messagebox.show("\n Service Request Submitted \n \n \n \n \n Disclaimer \n \n *  Kindly note that it may take up to 1 hr. to see your request logged under Track Request.", "Service Request", Messagebox.OK,Messagebox.EXCLAMATION);
            gridLists = new FeedbackServiceImpl().getCustomerFeedbackList("");
            saveusage("service_request");
            System.out.println("feedback1111:-"+feedback);
            System.out.println("gridLists:-"+gridLists);
            typegroup.setSelectedItem(null);
            //subtype.setSelectedItem(null);

            subject.setText(null);
            description.setText(null);

            int feedbackID = mfeedback.getNV_Customer_Feedback_ID();
            System.out.println("mfeedback.getNV_Customer_Feedback_ID()"+mfeedback.getNV_Customer_Feedback_ID());
            try{
                SfdcCaseCreating contactcase = new SfdcCaseCreating(Asset,feedbackID,Type,Project,Subject,Description,AccountName);
                contactcase.createCase(true);
            }catch (Exception e) {
                // TODO: handle exception
                e.printStackTrace();
            }
        }
    }
    else
    {
        Messagebox.show("Please fill mandatory Details", "Service Request", Messagebox.OK, Messagebox.ERROR);
    }
    //mfeedback.setSubType(Subtype);
}

public Listitem getFeedback() {
    return feedback;
}

public void setFeedback(Listitem feedback) {
    this.feedback = feedback;
}

// String Customer_Code = Sessions.getCurrent().getAttribute("CustomerCode").toString();

ProjectOverview overview = new ProjectOverview();
public ProjectOverview getOverview() {
    return overview;
}
public void setOverview(ProjectOverview overview) {
    this.overview = overview;
}


SessionSet setsession = new SessionSet();
public SessionSet getSetsession() {
    return setsession;
}
public void setSetsession(SessionSet setsession) {
    this.setsession = setsession;
}


@NotifyChange("setsession")
@SuppressWarnings("null")
@Listen("onClick = #projectlink")
public void showProject()
{

    tabbox.setSelectedPanel(projectview);

    tabproject.setVisible(true);
    //tabflat.setVisible(false);
    tabmyprofile.setVisible(false);
    tabgalery.setVisible(false);
    tabaccount.setVisible(false);
    tabdispatch.setVisible(false);
    tabrefer.setVisible(false);
    tabwrite.setVisible(false);
    //tabprogress.setVisible(false);
    //tabrequest.setVisible(false);
    //tabresopns.setVisible(false);
    tabcontact.setVisible(false);
    saveusage("project_overview");
    tabfaq.setVisible(false);
    tabkowledge.setVisible(false);
    //tabconstruction.setVisible(false);
    //tabupload.setVisible(false);


    /*if(Sessions.getCurrent().getAttribute("isCRCAdmin").toString() != null && Sessions.getCurrent().getAttribute("isCRCFlag").toString().equals("true"))
    {
        String Kunnr = Sessions.getCurrent().getAttribute("kunnrcrc").toString();
        request = (HttpServletRequest)Executions.getCurrent().getNativeRequest();
        int custCode = Integer.parseInt(Kunnr);
        ProjectOverview overview = new ProjectOverviewServiceImpl().getProjectOverview(custCode, request);
        SessionSet setsession1 = new ProjectOverviewServiceImpl().getSessionSet(custCode, request);

        System.out.println("setsession:--"+setsession1.getDescription());

        System.out.println("overview1273:-"+overview.getDescription());

        Sessions.getCurrent().setAttribute("CustomerCode", Kunnr);
    }
    if((Sessions.getCurrent().getAttribute("isDomestic").toString()!=null || Sessions.getCurrent().getAttribute("isCustomer").toString()!=null)
             && Sessions.getCurrent().getAttribute("isCRCFlag").toString().equals("false"))
    {
        String Customer_Code = Sessions.getCurrent().getAttribute("CustomerCode").toString();
        Sessions.getCurrent().setAttribute("CustomerCode", Customer_Code);
        int custCode = Integer.parseInt(Customer_Code);
        System.out.println("custCode:-"+custCode);
        request = (HttpServletRequest)Executions.getCurrent().getNativeRequest();
        ProjectOverview overview = new ProjectOverviewServiceImpl().getProjectOverview(custCode, request);
        System.out.println("overview1286:-"+overview);
    }
    */

    //Changed by satheesh for speedup portal
    String Customer_Code = Sessions.getCurrent().getAttribute("CustomerCode").toString();
    Sessions.getCurrent().setAttribute("CustomerCode", Customer_Code);
    int custCode = Integer.parseInt(Customer_Code);
    request = (HttpServletRequest)Executions.getCurrent().getNativeRequest();
    ProjectOverview overview = new ProjectOverviewServiceImpl().getProjectOverview(custCode, request);
    imageicon.setSrc(overview.getImage());
    project_logo.setSrc(overview.getProject_logo());
    description1.setValue(overview.getDescription());
    url.setHref(overview.getUrl());
    regional.setValue(overview.getRegionaloffice());
    siteoffice.setValue(overview.getSiteoffice());
    headoffice.setValue(overview.getHeadoffice());
    regioncontact.setValue(overview.getRegioncontact());
    hocontact.setValue(overview.getHocontact());
    tollfree.setValue(overview.getTollfree());

// overview.setDescription(description) /Model model = null; model.addAttribute("overview", overview); System.out.println("overview:-"+overview);/

}




CRCAdmin crcadmin = new CRCAdmin();
public CRCAdmin getCrcadmin() {
    return crcadmin;
}
public void setCrcadmin(CRCAdmin crcadmin) {
    this.crcadmin = crcadmin;
}



@Listen("onClick=#search1")
public void faqsearchcrc()
{
    customerService = new CustomerServiceImpl();
    customerService.setNvCustomerDao(new NVCustomerDaoImpl());
    projectoverview = new ProjectOverviewServiceImpl();
    flatsummary = new FlatServicesImpl();
    payservice = new PaymentSummaryServicesImpl();
    profileservice = new MyProfileServiceImpl();
    faqservice = new FaqServiceImpl();
    billingService = new BillingPlanServiceImpl();
    adminsearch1.getValue();
    System.out.println("Text Value In Filter:="+adminsearch1.getValue());
    Sessions.getCurrent().setAttribute("flatcodecrc", adminsearch1.getValue());

    crcadmin = new CRCServiceImpl().getCRCAdminList(adminsearch1.getValue());
    System.out.println("crcadmin.getKunnr():-"+crcadmin.getKunnr()+"Project Code:-"+crcadmin.getProjectcode()+"Tower Name:-"+crcadmin.getTowername());
    Sessions.getCurrent().setAttribute("kunnrcrc", crcadmin.getKunnr());
    Sessions.getCurrent().setAttribute("NV_Customer_ID", crcadmin.getNv_customer_ID());
    Sessions.getCurrent().setAttribute("AD_User_ID", crcadmin.getAD_User_ID());
    Sessions.getCurrent().setAttribute("CustomerCode", crcadmin.getKunnr());
    Sessions.getCurrent().setAttribute("Flatcode", adminsearch1.getValue());
    this.customer = customerService.getCustomerDetail(crcadmin.getNv_customer_ID(),(HttpServletRequest)Executions.getCurrent().getNativeRequest());
    this.flat = flatsummary.getFlat(crcadmin.getNv_customer_ID(), (HttpServletRequest)Executions.getCurrent().getNativeRequest()); 
    this.overview1 = projectoverview.getProjectOverview(crcadmin.getNv_customer_ID(), (HttpServletRequest)Executions.getCurrent().getNativeRequest());
    this.summary = payservice.getPaymentSummary(crcadmin.getNv_customer_ID(), (HttpServletRequest)Executions.getCurrent().getNativeRequest());
    System.out.println("summary:-");
    this.myprofilecrc = profileservice.getMyprofile(crcadmin.getNv_customer_ID(), (HttpServletRequest)Executions.getCurrent().getNativeRequest());

// this.faq = faqservice.getCustomerFaqList(" f.projectcode='"+crcadmin.getProjectcode()+"' and f.towername='"+crcadmin.getTowername()+"' order by created desc"); this.faq = faqservice.getCustomerFaqList(" f.projectcode='"+crcadmin.getProjectcode()+"' order by rankno,created desc "); this.plan = billingService.getBillinPlanList(""); // System.out.println("faq1650:-"+faq.get(1).toString());

// faqprojectname.setValue(faq.get(1).toString());

    ReferFriendController refer = new ReferFriendController();
    refer.getReferfriendlist();
    refer.getReferlist();
    refer.getRefer();
    System.out.println("refer.getReferfriendlist():-"+refer.getReferfriendlist()+"refer.getReferlist():-"+refer.getReferlist()+"refer.getRefer():-"+refer.getRefer());

    name.setValue(customer.getFirstName());
    firstname.setValue(customer.getFirstName());
    custcode.setValue(customer.getCustomerCode());
    bookingid.setValue(flat.getBookingid());
    projectname1.setValue(flat.getProjectname());
    allatment.setValue(flat.getAllotmentdate());
    flatno.setValue(flat.getFlatno_flatid());
    flattype.setValue(flat.getFlattype());
    agreement.setValue(flat.getAggreementregdate());
    consideration.setValue(flat.getConsiderationvalue());
    wing.setValue(flat.getWing());
    pcode.setValue(flat.getProjectcode());
    project_logo.setSrc(overview1.getProject_logo());
    description1.setValue(overview1.getDescription());
    url.setHref(overview1.getUrl());
    regional.setValue(overview1.getRegionaloffice());
    siteoffice.setValue(overview1.getSiteoffice());
    headoffice.setValue(overview1.getHeadoffice());
    regioncontact.setValue(overview1.getRegioncontact());
    hocontact.setValue(overview1.getHocontact());
    tollfree.setValue(overview1.getTollfree());
    imageicon.setSrc(overview1.getImage());
    projectsummary.setValue(summary.getProjectName());
    flatcodesummary.setValue(summary.getFlatcode());
    ccodesummary.setValue(summary.getCustomercode());
    totalsummary.setValue(summary.getTotalcost());
    paidsummary.setValue(summary.getPaidamount());
    balancesummary.setValue(summary.getBalanceamount());
    birthdate.setValue(myprofilecrc.getBirthdate());
    mobileno1.setValue(myprofilecrc.getMobilenumber());
    telno.setValue(myprofilecrc.getTelephonenumber());
    email.setValue(myprofilecrc.getEmail());
    state1.setValue(myprofilecrc.getState());
    postalcode.setValue(myprofilecrc.getPostalcode());
    presentaddress.setValue(myprofilecrc.getPresentaddress());
    perminentaddress.setValue(myprofilecrc.getPerminentaddress());

    /*List<Faq> faqlink = new ArrayList<Faq>();

    for(Faq faw : faq)
    {
        Faq fa = new Faq();

// System.out.println("faw.getProjectname():-"+faw.getProjectname()); fa.setProjectname(faw.getProjectname()); fa.setTowername(faw.getTowername()); fa.setTopic(faw.getTopic()); fa.setQuestion(faw.getQuestion()); fa.setReplay(faw.getReplay()); fa.setUpdationdate(faw.getUpdationdate());

        faqlink.add(fa);
    }*/

// BindUtils.postGlobalCommand(null, null, "FilterFaqData", null);

    /*FaqUIController faqcontroller = new FaqUIController();
    System.out.println("faqcontroller:-"+faqcontroller);
    System.out.println("faqcontroller.getFaqList():-"+faqcontroller.getFaqList());*/

// createPaymentDetails(crcadmin.getKunnr(),fromDate1,toDate1);

}

/* @Listen("onClick=#search") public void faqsearch() { adminsearch.getValue(); System.out.println(); }*/

@Listen("onClick=#searchShip2")
public void usagereportWithDate()
{
    createUsageGrid(CustomerCode,fromDate2,toDate2);
}

//payment details
@Listen("onClick=#beforesubmit")
public void afterSubmit()
{
    System.out.println("Select on Flat code:-"+CustomerCode);
    //filter.setVisible(true);
    beforesubmit.setVisible(false);
    aftersubmit.setVisible(true);
    //filter.setVisible(true);
    export_pdf.setVisible(true);
    export_exel.setVisible(true);
    paymentDetailGrid.setVisible(true);
    terms.setVisible(true);
    saveusage("report_statmentofaccount");
    //export_print.setVisible(true);
    String CrcAdmin = "";

    if(Sessions.getCurrent().getAttribute("isCRCAdmin").toString() != null && Sessions.getCurrent().getAttribute("isCRCFlag").toString().equals("true"))
    {
        String Kunnr = Sessions.getCurrent().getAttribute("kunnrcrc").toString();
        createPaymentDetails(Kunnr,fromDate1,toDate1);
    }
    if((Sessions.getCurrent().getAttribute("isDomestic").toString()!=null || Sessions.getCurrent().getAttribute("isCustomer").toString()!=null)
             && Sessions.getCurrent().getAttribute("isCRCFlag").toString().equals("false"))
    {
        createPaymentDetails(CustomerCode,fromDate1,toDate1);
    }


}
//payment details
@Listen("onClick=#aftersubmit")
public void hideButton()
{
    beforesubmit.setVisible(true);
    //filter.setVisible(false);
    aftersubmit.setVisible(false);
    paymentDetailGrid.setVisible(false);
    export_pdf.setVisible(false);
    //filter.setVisible(false);
    export_exel.setVisible(false);
    //export_print.setVisible(false);
    terms.setVisible(false);

}

//paymnent details
@Listen("onClick=#beforesubmit")
public void createPaymentDetails1()
{
    aftersubmit.setVisible(true);

}



//static String openReport;

public void createPaymentDetails(String whereCondition,Datebox fromDate,Datebox toDate)
{
    String from = fromDate1.getText();
    String todate = toDate1.getText();
    System.out.println("Eneter Grid of payment Details");
    Sessions.getCurrent().setAttribute("openReport", "PaymentDetails");
    //openReport="Payment Details";
    Columns cols = paymentDetailGrid.getColumns();
    System.out.println("cols:-"+cols);

    if(cols != null)
    {
        paymentDetailGrid.removeChild(cols);
    }
    cols = new Columns();
    cols.setMenupopup("auto");

    try
    {
        Column col = new Column("Date");
        //col.setAttribute("attribute", "Date");
        //col.setContext("Platinum");
        //col.setSort("auto");
        col.setAttribute("attribute", "Date");
        col.setSortAscending(new SortControl(0,"Date").getAscendingComparator());
        col.setSortDescending(new SortControl(0,"Date").getDescendingComparator());
        col.setStyle("width: 105px;");
        cols.appendChild(col);
        col = new Column("Due Date");
        //col.setSort("auto");
        col.setAttribute("attribute", "Date");
        col.setSortAscending(new SortControl(1,"Date").getAscendingComparator());
        col.setSortDescending(new SortControl(1,"Date").getDescendingComparator());
        col.setStyle("width: 105px;");
        cols.appendChild(col);
        col = new Column("Particulars");
        col.setSort("auto");
        col.setStyle("width: 300px;");
        cols.appendChild(col);
        /*col = new Column("Opening Balance");
        col.setSort("auto");
        col.setStyle("min-width: 100px;");
        cols.appendChild(col);*/
        col = new Column("Bill/Invoice");
        /*col.setSortAscending(new SortControl(3,"BigDecimal").getAscendingComparator());
        col.setSortDescending(new SortControl(3,"BigDecimal").getDescendingComparator());*/
        col.setStyle("width: 150px;");
        cols.appendChild(col);
        col = new Column("Collection");
        /*col.setSortAscending(new SortControl(4,"BigDecimal").getAscendingComparator());
        col.setSortDescending(new SortControl(4,"BigDecimal").getDescendingComparator());*/
        col.setStyle("width: 200px;");
        cols.appendChild(col);
        //Added on 08-08-2014
        /*col = new Column("Download Invoice");
        col.setStyle("width: 150px;");
        cols.appendChild(col);

        col = new Column("Download Receipt");
        col.setStyle("width: 150px;");
        cols.appendChild(col);*/

        /*col = new Column("Receive Date");
        col.setSortAscending(new SortControl(5,"Date").getAscendingComparator());
        col.setSortDescending(new SortControl(5,"Date").getDescendingComparator());*/
        //cols.appendChild(col);
    }
    catch(Exception ex)
    {
        ex.printStackTrace();
    }
    cols.setSizable(true);

    paymentDetailGrid.appendChild(cols);
    System.out.println("CustomerCode:----"+CustomerCode);
    System.out.println("flatttt:----"+whereCondition);
    List<PaymentDetails> paDetails = new LinkedList<PaymentDetails>();
    PaymentDetailsServicesImpl paymentDetailsServicesImpl = new PaymentDetailsServicesImpl();

    paDetails = paymentDetailsServicesImpl.getPaymentDetailsList(whereCondition,from,todate);
    setPaymentDetails(paDetails);

    PaymentDetails pbalance = new PaymentDetails();
    PaymentDetailsServicesImpl paymentDetailsServicesImpl2 = new PaymentDetailsServicesImpl();
    //pbalance = paymentDetailsServicesImpl2.getPaymentDetails(CustomerCode,from,todate);
    setPaymentDetailsBalance(paDetails.get(paDetails.size()-1));

    PaymentOpening pOBalance = new PaymentOpening();
    PaymentDetailsServicesImpl paymentDetailsServicesImpl3 = new PaymentDetailsServicesImpl();
    pOBalance = paymentDetailsServicesImpl3.getPaymentOpening(whereCondition, from, todate);
    setPaymentOpeningBalance(pOBalance);


    //For Invoice List Added by Satheesh

    /*List<PaymentDetails> PInvoice = new LinkedList<PaymentDetails>();
    PaymentDetailsServicesImpl PInvoiceImpl = new PaymentDetailsServicesImpl();

    PInvoice = PInvoiceImpl.getPaymentDetailsList(whereCondition,from,todate);
    setPaymentInvoice(PInvoice);*/


}

public void setPaymentOpeningBalance(PaymentOpening payopening)
{
    Rows rows = paymentDetailGrid.getRows();
    if(rows!=null)
    {
        paymentDetailGrid.removeChild(rows);
    }
    Row row = null;
    Label label = null;
    row = new Row();
    row.appendChild(new Label(""));
    row.appendChild(new Label(""));
    label = new Label("Opening Balance");
    label.setStyle("font-weight: bold");

    //row.setStyle("font:weight");
    row.appendChild(label);

    label = new Label(payopening.getOpeningbalance());
    //System.out.println("pdDetails.getBalance()1050:-"+pdDetails.getBalance());
    label.setStyle("font-weight: bold;float:right");
    row.appendChild(label);
    row.appendChild(new Label(""));
    row.appendChild(new Label(""));
    //row.appendChild(new Label(""));

    rows.insertBefore(row, rows.getFirstChild());

    /*rows.appendChild(row);*/

    paymentDetailGrid.appendChild(rows);
}


public void setPaymentDetails(List<PaymentDetails> paDetails)
{
    PaymentDetails paDetails2 = new PaymentDetails();

    String columnName[]={"Date","Due Date","Particulars","Bill/Invoice","Collection"};
    Rows rows = paymentDetailGrid.getRows();
    System.out.println("Rows..........."+rows);
    if(rows!=null)
    {
        paymentDetailGrid.removeChild(rows);
    }

    rows = new Rows();

    Row row = null;
    Label label = null;
    BigDecimal Debitamount = new BigDecimal(0);
    Button button = null;
    Button button1 = null;


    for(PaymentDetails payment : paDetails)
    {

        row = new Row();
        label = new Label(payment.getDate());
        row.appendChild(label);

        label = new Label(payment.getDuedate());
        row.appendChild(label);

        label = new Label(payment.getParticulars());
        row.appendChild(label);

        label = new Label(payment.getDebitamount());
        label.setStyle("float:right;");
        row.appendChild(label);

        label = new Label(payment.getCreditamount());
        label.setStyle("float:right");
        row.appendChild(label);

        /*row.setAttribute("reportColumn", columnName);
        row.setStyle("cursor:hand;cursor:pointer");
        row.addEventListener("onClick", new ShowRowContent());*/


        //Added by satheesh for invoice download
        /*if(payment.getInvoice() != null && payment.getInvoice().length() > 0 )
        {
            label = new Label(payment.getInvoice());

            button = new Button();
            button.setLabel(payment.getInvoice());
//          if(payment.getInvoice() != null && payment.getInvoice().length() > 0)
                button.setStyle("background: url(css/images/download.png) no-repeat; width: 20px; height:25px; border:0px; padding:0px;");

            row.appendChild(button);
        }
        row.setStyle("cursor:hand;cursor:pointer;");

        String Invoice = payment.getInvoice();
        String customerCode = payment.getCustomercode();
        System.out.println("Get receipt:-"+payment.getReceipt());
        boolean isInvoice = payment.isInvoice();
        System.out.println("isInvoice:-1165:-"+isInvoice);



            System.out.println("Invoice:-"+Invoice);
            label.addEventListener("onClick", new PDFControllerInvoice(Invoice,customerCode));*/

// row.appendChild(label);

        /*if(payment.getReceipt() != null && payment.getReceipt().length() > 0 )
        {
            label = new Label(payment.getReceipt());

            button1 = new Button();
            button1.setLabel(payment.getInvoice());
            button1.setStyle("background: url(css/images/download.png) no-repeat; width: 20px; height:25px; border:0px; padding:0px;");

            row.appendChild(button1);
        }
        row.setStyle("cursor:hand;cursor:pointer;");

        String Receipt = payment.getReceipt();
        System.out.println("Receipt No:-"+Receipt);
        boolean isReceipt = payment.isInvoice();

        if(isReceipt == false)
        {
            row.addEventListener("onClick", new PDFControllerReceipt(Receipt,customerCode));

// row.appendChild(label); }*/

        /*row.setAttribute("reportColumn", columnName);
        row.setStyle("cursor:hand;cursor:pointer");
        row.addEventListener("onClick", new ShowRowContent());*/

        /*if(isInvoice==true)
        {
            row.setAttribute("reportColumn", columnName);
            row.setStyle("cursor:hand;cursor:pointer");
            row.addEventListener("onClick", new ShowRowContent());

        }*/

        row.setAttribute("reportColumn", columnName);
        row.setStyle("cursor:hand;cursor:pointer");
        row.addEventListener("onClick", new ShowRowContent());

        rows.appendChild(row);

    }

    paymentDetailGrid.appendChild(rows);
}

public void setPaymentDetailsBalance(PaymentDetails pdDetails)
{
    Rows rows = paymentDetailGrid.getRows();
    if(rows!=null)
    {
        paymentDetailGrid.removeChild(rows);
    }

    Row row = null;
    Label label = null;
    row = new Row();
    row.appendChild(new Label(""));
    row.appendChild(new Label(""));
    row.appendChild(new Label(""));
    label = new Label(pdDetails.getTotalamount());
    System.out.println("pdDetails.getTotalamount()"+pdDetails.getTotalamount());
    label.setStyle("font-weight: bold;float:right");
    row.appendChild(label);
    label = new Label(pdDetails.getPaidamount());
    System.out.println("pdDetails.getPaidamount()"+pdDetails.getPaidamount());
    label.setStyle("font-weight: bold;float:right");
    row.appendChild(label);
    rows.appendChild(row);

    row = new Row();
    row.appendChild(new Label(""));
    row.appendChild(new Label(""));
    label = new Label("Balance");
    label.setStyle("font-weight: bold");
    //row.setStyle("font:weight");
    row.appendChild(label);

    label = new Label(pdDetails.getBalance());
    //System.out.println("pdDetails.getBalance()1050:-"+pdDetails.getBalance());
    label.setStyle("font-weight: bold;float:right");
    row.appendChild(label);
    row.appendChild(new Label(""));
    row.appendChild(new Label(""));
    //row.appendChild(new Label(""));
    rows.appendChild(row);

    paymentDetailGrid.appendChild(rows);
}


/**Added by shrikant for dynamic images---
 * showImages takes the clicked month as parameter
 * and changes the list of images */

@Command
@NotifyChange("imgList")
public void showImages(@BindingParam("ref") String label,@BindingParam("iref") String id)
{
    imgList = getImageList(label);
    Clients.evalJavaScript("  $('.project_box .month_g').colorbox({ rel: 'group42014' })");
    Clients.evalJavaScript(" $('a.activator').parent().removeClass('tab_active') ");
    Clients.evalJavaScript(" $('a#"+id+"').parent().addClass('tab_active') ");
}


public List<Year> getYearList()
{
    List<Year> yrs = new LinkedList<Year>();
    /*System.out.println("overview.getCompany():-"+overview.getCompany());
    System.out.println("overview.getProjectname():-"+overview.getProjectname());
    System.out.println("flat.getTowername():-"+flat.getTowername());*/
    /*File folder = new File(request.getRealPath("/images/"+overview.getCompany()+"_"+overview.getProjectname()+"/construction/"+flat.getTowername()));*/
    /*ProjectOverview overview = (ProjectOverview)Sessions.getCurrent().getAttribute("overview");*/
     Flat flat= (Flat)Sessions.getCurrent().getAttribute("flat");

    System.out.println(" in YEAR LIST - "+IMAGE_PATH+"images\\"+flat.getProjectname()+"\\construction\\"+flat.getWing());
    File folder = new File(IMAGE_PATH+"images\\"+flat.getProjectname()+"\\construction\\"+flat.getWing());
    List<String> folders = getSubfoldrs(folder);
    if(folders!=null)
    {
        for(String filename : folders)
        {
            Year year = new Year();
            year.setyName(filename);
            year.setyValue(filename);
            year.setSelected(filename.equals(String.valueOf(Calendar.getInstance().getTime().getYear()+1900)));
            yrs.add(year);
        }
    }
    return yrs;
}

public List<String> getSubfoldrs(File folder)
{
    List<String> folders = new LinkedList<String>();
    File[] listOfFiles = folder.listFiles();
     if(listOfFiles!=null)
     {
         for (int i = 0; i < listOfFiles.length; i++) {
             if(listOfFiles[i].isDirectory())
             {
                 folders.add(listOfFiles[i].getName());
             }
         }
     }
     return folders;
}


/**yearSelect takes the seleted year as parameter 
 * AND changes the list of month folders in this year**/
@Command
@NotifyChange({"months","imgList"})
public void yearSelect(@BindingParam("ref") Listitem selected )
{
    slctdYear = selected.getValue();
    months = getMonthFolderList();

    if(months!=null && months.size()>0)
    {
        Month month= months.get(0);
        imgList = getImageList(month.getmName());
    }
    else
        imgList = new LinkedList<ImageModel>(); 

    Clients.evalJavaScript("  $('.project_box .month_g').colorbox({ rel: 'group42014' })");
    Clients.evalJavaScript(" $('ul.uact li:first-child').addClass('tab_active')");
}


public List<Month> getMonthFolderList()
{
    Map<String, Integer> map = new HashMap<String, Integer>();
    map.put("Jan", 1);
    map.put("Feb", 2);
    map.put("Mar", 3);
    map.put("Apr", 4);
    map.put("May", 5);
    map.put("Jun", 6);
    map.put("Jul", 7);
    map.put("Aug", 8);
    map.put("Sep", 9);
    map.put("Oct", 10);
    map.put("Nov", 11);
    map.put("Dec", 12);

    List<Month> mnths = new LinkedList<Month>();
    request = (HttpServletRequest)Executions.getCurrent().getNativeRequest();
    /*ProjectOverview overview = (ProjectOverview)Sessions.getCurrent().getAttribute("overview");*/
     Flat flat= (Flat)Sessions.getCurrent().getAttribute("flat");
    /*File folder = new File(request.getRealPath("/images/"+overview.getCompany()+"_"+overview.getProjectname()+"/construction/"+flat.getTowername()+"/"+slctdYear));*/
    File folder = new File(IMAGE_PATH+"images\\"+flat.getProjectname()+"\\construction\\"+flat.getWing()+"\\"+slctdYear+"");
    System.out.println("folder:-"+folder);

    List<String> folders = getSubfoldrs(folder);
    if(folders!=null)
    {
        for(String filename : folders)
        {
            Month month = new Month();
            month.setmName(filename);
            if(map.get(month.getmName())!=null)
                month.setmValue(map.get(month.getmName()));// changed by shrikant to sort the list
            mnths.add(month);
        }
    }

    Collections.sort(mnths);

    return mnths;

}

public List<ImageModel> getImageList(String month)
{
    List<ImageModel> imageList = new LinkedList<ImageModel>();

    request = (HttpServletRequest)Executions.getCurrent().getNativeRequest();
    /*ProjectOverview overview = (ProjectOverview)Sessions.getCurrent().getAttribute("overview");*/
     Flat flat= (Flat)Sessions.getCurrent().getAttribute("flat");
    /*File folder = new File(request.getRealPath("/images/"+overview.getCompany()+"_"+overview.getProjectname()+"/construction/"+flat.getTowername()+"/"+slctdYear+"/"+month));*/
    File folder = new File(IMAGE_PATH+"images\\"+flat.getProjectname()+"\\construction\\"+flat.getWing()+"\\"+slctdYear+"\\"+month);

    System.out.println("folder Name for getting Img List:-"+folder);
    File[] listOfFiles = folder.listFiles();
    System.out.println("folder Name for getting Img List listOfFiles:-"+listOfFiles);
    String projectName = flat.getProjectname();
    /*String companyName = overview.getCompany();*/
    /*if(companyName!=null)
        companyName = companyName.toLowerCase();
    if(projectName!=null)
        projectName = projectName.toLowerCase();*/


    //Gallery Approve added on 23-05-2013

    PreparedStatement pstmt = null;
    ResultSet rs = null;
    int nv_uploadgallery_id = 0;

    try{
        String sql = " select nv_uploadgallery_id from nv_uploadgallery " +
                    " where project_name='"+flat.getProjectname()+"' and tower_name='"+flat.getWing()+"'" +
                            " and year='"+slctdYear+"' and month='"+month+"'";
        System.out.println(" Sql Statment for Hrader:-"+sql);
        pstmt = DB.prepareStatement(sql, null);
        rs=pstmt.executeQuery();
        rs.next();
        System.out.println(" rs.getString(1) :-"+rs.getString(1));
        nv_uploadgallery_id = Integer.parseInt(rs.getString(1));
    }
    catch(SQLException e){
        e.printStackTrace();
    }
    finally{
        DB.close(rs, pstmt);
    }

    List<MUploadGallerySHeader> gallerySList = new Query(Env.getCtx(), MUploadGallerySHeader.Table_Name, " nv_uploadgallery_id="+ nv_uploadgallery_id+" and isapproved='Y' " , null).setOrderBy("imagedate").setOnlyActiveRecords(true).list();

    for(MUploadGallerySHeader gallery : gallerySList)
    {

        System.out.println();
        ImageModel m1 = new ImageModel();
        String imgName = gallery.getImageName();
        String suffix = imgName.substring(imgName.lastIndexOf("."));

        m1.setLarge("/image/"+projectName+"/construction/"+flat.getWing()+"/"+slctdYear+"/"+month+"/large/"+gallery.getImageName());
        System.out.println("Large Image Path name:-"+"/image/"+projectName+"/construction/"+flat.getWing()+"/"+slctdYear+"/"+month+"/large/"+gallery.getImageName());
        m1.setThumb("/image/"+projectName+"/construction/"+flat.getWing()+"/"+slctdYear+"/"+month+"/thumb/"+gallery.getImageName());
        //m1.setImagename(gallery.getImageName().substring(0).replace(".jpg", ""));
        m1.setImagename(gallery.getImageName().replaceAll("_", " ").replaceAll(suffix, "").substring(1));
        //m1.setImagename(gallery.getImageName().substring(0).replace(".png", ""));
        imageList.add(m1);

    }




    /*if(listOfFiles!=null)
    {
         for (int i = 0; i < listOfFiles.length; i++) 
         {
            if(listOfFiles[i].isFile())
            {
                System.out.println();
                ImageModel m1 = new ImageModel();
                m1.setLarge("/image/"+projectName+"/construction/"+flat.getWing()+"/"+slctdYear+"/"+month+"/"+listOfFiles[i].getName());
                m1.setThumb("/image/"+projectName+"/construction/"+flat.getWing()+"/"+slctdYear+"/"+month+"/thumb/"+listOfFiles[i].getName());
                m1.setImagename(listOfFiles[i].getName().substring(0).replace(".jpg", " "));
                imageList.add(m1);
            }
         }
    }*/
    return imageList;
}


List<FlatCode> flatcodeList = new FlatCodeServiceImpl().getFlatCodeList("");

FlatCode flatcode = new FlatCode(); 

public FlatCode getFlatcode() {
    return flatcode;
}

public void setFlatcode(FlatCode flatcode) {
    this.flatcode = flatcode;
}

public List<FlatCode> getFlatcodeList() {
    return flatcodeList;
}

public void setFlatcodeList(List<FlatCode> flatcodeList) {
    this.flatcodeList = flatcodeList;
}


/* Usage Report 04 June 2014 */

public void createUsageGrid(String customerCode,Datebox fromDate,Datebox toDate)
{
    Date DateFrom,DateTo;

    System.out.println("fromDate2.getValue():-"+fromDate2.getValue()+"toDate2.getValue():-"+toDate2.getValue());
    DateFrom = fromDate2.getValue();
    DateTo = toDate2.getValue();
    List<PortalUsage> portalUsages = new LinkedList<PortalUsage>();
        Sessions.getCurrent().setAttribute("openReport", "UsageReport");
        //boolean isDomestic = (Boolean) Sessions.getCurrent().getAttribute("isDomestic");
        Columns cols=usageGrid.getColumns();    
        if(cols!=null)
        {
            usageGrid.removeChild(cols);
            System.out.println("Enter Grid:-"+cols);
        }

        cols = new Columns();
        cols.setMenupopup("auto");

        try{
        Column col = new Column("Customer Name");
        col.setSort("auto");            
        cols.appendChild(col);
        col.setStyle("min-width: 100px;");

        col = new Column("Flat Code");
        col.setSort("auto");            
        cols.appendChild(col);
        col.setStyle("min-width: 100px;");

        col = new Column("Login Date");
        col.setSort("auto");
        col.setAttribute("attribute", "Date");
        col.setSortAscending(new SortControl(2,"Date").getAscendingComparator());
        col.setSortDescending(new SortControl(2,"Date").getDescendingComparator());
        cols.appendChild(col);
        col.setStyle("min-width: 150px;");

        col = new Column("Logins");
        col.setSort("auto");
        col.setAttribute("attribute", "OnlyFrom");
        col.setStyle("min-width: 150px;");
        cols.appendChild(col);



        col = new Column("MyProfile");
        col.setSort("auto");
        col.setStyle("min-width: 100px;");
        cols.appendChild(col);


        col = new Column("Project Overview");
        col.setSort("auto");
        col.setStyle("min-width: 100px;");
        cols.appendChild(col);

        col = new Column("Construction Status");
        col.setSort("auto");
        col.setStyle("min-width: 100px;");
        cols.appendChild(col);

        col = new Column("Statement Of Account");
        col.setSort("auto");
        col.setStyle("min-width: 100px;");
        cols.appendChild(col);

        col = new Column("Dispatch Details");
        col.setSort("auto");
        col.setStyle("min-width: 150px;");
        cols.appendChild(col);

        col = new Column("Refer a Friend");
        col.setSort("auto");
        col.setStyle("min-width: 150px;");
        cols.appendChild(col);


        col = new Column("Service Request");
        col.setSort("auto");
        col.setStyle("min-width: 200px;");
        cols.appendChild(col);

        col = new Column("Contact Us");
        col.setSort("auto");
        col.setStyle("min-width: 200px;");
        cols.appendChild(col);


        }
        catch(Exception ex){}

        cols.setSizable(true);
        usageGrid.appendChild(cols);
        System.out.println("@@@@@@@@@@@@@@@@:-"+cols);

        boolean isLastPage = false;

        String selectFlat = flatcode.getFlatcode();
        System.out.println("Selected Flat Code:-"+selectFlat);
        StringBuffer where = new StringBuffer("");

        /*if(customerCode!=null && customerCode.length()>0)
            where.append(" AND customercode ='").append(customerCode).append("' ");*/

        if(DateFrom!=null && DateTo!=null)
            where.append(" AND LoginTime between '"+DateFrom+"' AND '"+DateTo+"' ");
        else    if(DateFrom!= null)
            where.append(" AND LoginTime = '"+DateFrom+"' ");
        else
            if(DateTo!=null)
                where.append(" AND LoginTime <= '"+DateTo+"'");
        /*if(isDomestic)
            where.append(" AND isDomestic='Y'");
        else
            where.append(" AND isDomestic='N'");*/

        portalUsages = new PortalUsageServiceImpl().getportalUsageList(where.toString());
        Sessions.getCurrent().setAttribute("list", portalUsages);
        setPortalUsageRows(portalUsages,isLastPage);
        System.out.println("size of list :- "+portalUsages.size());

        usageGrid.setSizedByContent(true);
        usageGrid.setSpan(true);
        usageGrid.setEmptyMessage("No Records Found");
}




public void setPortalUsageRows(List<PortalUsage> portalUsages,boolean isLastPage){

    Rows rows = usageGrid.getRows();
//  boolean isDomestic = (Boolean) Sessions.getCurrent().getAttribute("isDomestic");

    String columnName[] = {"Customer Name","Flat code","Login Date","Logins","MyProfile","Project Overview","Construction Status","Statement Of Account","Dispatch Details","Refer a Friend","Servide Request","Contact Us"};

    if(rows!=null)
    {
        usageGrid.removeChild(rows);
    }
    rows = new Rows();
    Row row = null;
    Label label = null;
    BigDecimal NetValue = new BigDecimal(0);
    BigDecimal TaxableValue = new BigDecimal(0);
    BigDecimal Quantity = new BigDecimal(0);
    int myprofile=0; int projectovw=0; int constst =0; int referfrd = 0; int servrest = 0;
    int contactus = 0;  int disp = 0; int logins=0;int stmntact = 0;

    for(PortalUsage portalUsage  : portalUsages )
    {
        row = new Row();

        label = new Label(portalUsage.getCustomerName());
        //System.out.println("Customer Name:-"+portalUsage.getCustomerName());
        row.appendChild(label);

        label = new Label(portalUsage.getFlatcode());
        row.appendChild(label);

        label = new Label(portalUsage.getLogindate());
        row.appendChild(label);

        label = new Label(portalUsage.getLogins());
        logins = logins + Integer.parseInt(portalUsage.getLogins());
        row.appendChild(label);


        label = new Label(portalUsage.getMyprofile());
        myprofile = myprofile + Integer.parseInt(portalUsage.getMyprofile());
        row.appendChild(label);

        label = new Label(portalUsage.getProjectoverview());
        projectovw = projectovw + Integer.parseInt(portalUsage.getProjectoverview());
        row.appendChild(label);

        label = new Label(portalUsage.getContructionstatus());
        constst = constst + Integer.parseInt(portalUsage.getContructionstatus());
        row.appendChild(label);

        label = new Label(portalUsage.getStatementofaccount());
        stmntact = stmntact + Integer.parseInt(portalUsage.getStatementofaccount());
        row.appendChild(label);

        label = new Label(portalUsage.getDispatchdetails());
        disp = disp + Integer.parseInt(portalUsage.getDispatchdetails());
        row.appendChild(label);


        label = new Label(portalUsage.getReferfriend());
        referfrd = referfrd + Integer.parseInt(portalUsage.getReferfriend());
        row.appendChild(label);

        label = new Label(portalUsage.getServicerequest());
        servrest = servrest + Integer.parseInt(portalUsage.getServicerequest());
        row.appendChild(label);

        label = new Label(portalUsage.getContactus());
        contactus = contactus + Integer.parseInt(portalUsage.getContactus());
        row.appendChild(label);


        /*
        label = new Label(portalUsage.getQuantity());
        Quantity = Quantity.add(new BigDecimal(portalUsage.getQuantity().replaceAll(",", "")));
        label.setAttribute("InvoiceQnty", portalUsage.getQuantity());// SubTotal
        label.setStyle("float:right");
        row.appendChild(label);*/

        /*if(isDomestic)
            row.setAttribute("reportColumn", columnName1);*/

        row.setAttribute("reportColumn", columnName);
        row.setStyle("cursor:hand;cursor:pointer");
        row.addEventListener("onClick", new ShowRowContent());

        rows.appendChild(row);
    }

        row = new Row();
        label = new Label("");
        row.appendChild(label);

        label = new Label("");
        row.appendChild(label);

        label = new Label("");
        row.appendChild(label);

        label = new Label(String.valueOf(logins));
        row.appendChild(label);

        label = new Label(String.valueOf(myprofile));
        row.appendChild(label);

        label = new Label(String.valueOf(projectovw));
        row.appendChild(label);

        label = new Label(String.valueOf(constst));
        row.appendChild(label);

        label = new Label(String.valueOf(stmntact));
        row.appendChild(label);

        label = new Label(String.valueOf(disp));
        row.appendChild(label);

        label = new Label(String.valueOf(referfrd));
        row.appendChild(label);

        row.appendChild(label);



        label = new Label(String.valueOf(contactus));
        row.appendChild(label);

        rows.appendChild(row);
        row.setSclass("last");
        row.setStyle("background-color:#ffff33;");
    //}
        usageGrid.appendChild(rows);
}

public void saveusage(String ColumnName)
{
    int  NV_PortalUsage_ID=0;
    if(Sessions.getCurrent().getAttribute("NV_PortalUsage_ID")!=null)
    {
        NV_PortalUsage_ID = (Integer) Sessions.getCurrent().getAttribute("NV_PortalUsage_ID");
    }

    MPortalUsage mu = new MPortalUsage(Env.getCtx(), NV_PortalUsage_ID, null);
    if(mu.getNV_PortalUsage_ID() > 0)
    {
        mu.get_ValueAsInt(ColumnName);
        mu.set_CustomColumn(ColumnName, (mu.get_ValueAsInt(ColumnName)+1));
        mu.save();
    }
}


@Command
public void onCode()
{
    System.out.println("code.getCode()656:-"+code.getCode());
    System.out.println("code.getCode():-"+code.getCountryname());
    Sessions.getCurrent().setAttribute("CountryCode", code.getCode());
}
    //For Custom Constraints

    Constraint ctt = new Constraint() {
    @SuppressWarnings("null")
    public void validate(Component comp, Object value) throws WrongValueException {
        String valuecount = value.toString();
        int valuecc = valuecount.length();
        int fixedCount = 10;
        String countrycode=null;
        if (Sessions.getCurrent().getAttribute("CountryCode")==null)
            countrycode= "+91";
        countrycode = Sessions.getCurrent().getAttribute("CountryCode").toString();
            if(countrycode.equals("+91"))
            {
                if (value != null && fixedCount < valuecc || fixedCount > valuecc)
                {
                    throw new WrongValueException(comp, "Please enter 10 digits only");
                }
            }
        }
    };

    public Constraint getCtt() {
        return ctt;
    }
    public void setCtt(Constraint ctt) {
        this.ctt = ctt;
    }
    public Customer getCustomer() {
        return customer;
    }
    public Flat getFlat() {
        return flat;
    }
    public ProjectOverview getOverview1() {
        return overview1;
    }
    public PaymentSummary getSummary() {
        return summary;
    }
    public Myprofile getMyprofilecrc() {
        return myprofilecrc;
    }


    public List<BillingPlan> getbPlanList() {
        return bPlanList;
    }
    public List<ProjectName> getProjectNames() {
        return projectNames;
    }
    public void setProjectNames(List<ProjectName> projectNames) {
        this.projectNames = projectNames;
    }


    @Listen("onClick=#cancelWTS")
    public void createServiceRequestCancel()
    {
        typegroup.setSelectedItem(null);
        //subtype.setSelectedItem(null);
        //subtype1.setSelectedItem(null);
        //subtype2.setSelectedItem(null);
        //subtype3.setSelectedItem(null);
        subject.setText(null);
        description.setText(null);
    }



    @Listen("onClick=#customerlink")
    public void showProfile()
    {

        tabbox.setSelectedPanel(customerDetails);
        tabmyprofile.setVisible(true);
        //tabflat.setVisible(false);
        tabproject.setVisible(false);
        tabgalery.setVisible(false);
        tabaccount.setVisible(false);
        tabdispatch.setVisible(false);
        tabrefer.setVisible(false);
        tabwrite.setVisible(false);
        //tabprogress.setVisible(false);
        //tabrequest.setVisible(false);
        //tabresopns.setVisible(false);
        tabcontact.setVisible(false);
        //tabconstruction.setVisible(false);
        //tabupload.setVisible(false);
        saveusage("myprofile");
        tabfaq.setVisible(false);
        tabkowledge.setVisible(false);
        tabbplan.setVisible(false);
    }

    @Listen("onClick=#flatlink")
    public void showflats()
    {
        tabbox.setSelectedPanel(flatcollapse);
        tabmyprofile.setVisible(false);
        //tabflat.setVisible(true);
        tabproject.setVisible(false);
        tabgalery.setVisible(false);
        tabaccount.setVisible(false);
        tabdispatch.setVisible(false);
        tabrefer.setVisible(false);
        tabwrite.setVisible(false);
        //tabprogress.setVisible(false);
        //tabrequest.setVisible(false);
        //tabresopns.setVisible(false);
        tabcontact.setVisible(false);
        //tabconstruction.setVisible(false);
        //tabupload.setVisible(false);
        tabfaq.setVisible(false);
        tabkowledge.setVisible(false);
        tabbplan.setVisible(false);
    }
    @Listen("onClick=#gallerylink")
    public void showGallery()
    {

        tabbox.setSelectedPanel(gallery);
        tabgalery.setVisible(true);
        tabproject.setVisible(false);
        //tabflat.setVisible(false);
        tabmyprofile.setVisible(false);
        tabaccount.setVisible(false);
        tabdispatch.setVisible(false);
        tabrefer.setVisible(false);
        tabwrite.setVisible(false);
        //tabprogress.setVisible(false);
        //tabrequest.setVisible(false);
        //tabresopns.setVisible(false);
        tabcontact.setVisible(false);
        saveusage("construction_status");
        //tabconstruction.setVisible(false);
        //tabupload.setVisible(false);
        tabfaq.setVisible(false);
        tabkowledge.setVisible(false);
        tabbplan.setVisible(false);
    }

// int Customer_Code = Integer.parseInt(Sessions.getCurrent().getAttribute("CustomerCode").toString());

    @Listen("onClick=#payment")
    public void showData()
    {
        tabbox.setSelectedPanel(filterLayout1);
        tabaccount.setVisible(true);
        tabgalery.setVisible(false);
        tabproject.setVisible(false);
        //tabflat.setVisible(false);
        tabmyprofile.setVisible(false);
        tabdispatch.setVisible(false);
        tabrefer.setVisible(false);
        tabwrite.setVisible(false);
        //tabprogress.setVisible(false);
        //tabrequest.setVisible(false);
        //tabresopns.setVisible(false);
        tabcontact.setVisible(false);
        //tabconstruction.setVisible(false);
        //tabupload.setVisible(false);

// request = (HttpServletRequest)Executions.getCurrent().getNativeRequest();

// PaymentSummary paysum = new PaymentSummaryServicesImpl().getPaymentSummary(Customer_Code, request); tabfaq.setVisible(false); tabkowledge.setVisible(false); tabbplan.setVisible(false); }

    //Dispatch detail
    @Listen("onClick=#dispatch")
    public void showDetails()
    {

        tabbox.setSelectedPanel(filterLayout2);
        tabdispatch.setVisible(true);
        tabaccount.setVisible(false);
        tabgalery.setVisible(false);
        tabproject.setVisible(false);
        //tabflat.setVisible(false);
        tabmyprofile.setVisible(false);
        tabrefer.setVisible(false);
        tabwrite.setVisible(false);
        //tabprogress.setVisible(false);
        //tabrequest.setVisible(false);
        //tabresopns.setVisible(false);
        tabcontact.setVisible(false);
        saveusage("dispatch_details");
        //tabconstruction.setVisible(false);
        //tabupload.setVisible(false);
        tabfaq.setVisible(false);
        tabkowledge.setVisible(false);
        tabbplan.setVisible(false);
    }

    @Listen("onClick=#referlink")
    public void referAFriend()
    {
        tabbox.setSelectedPanel(refer);
        tabrefer.setVisible(true);
        tabdispatch.setVisible(false);
        tabaccount.setVisible(false);
        tabgalery.setVisible(false);
        tabproject.setVisible(false);
        //tabflat.setVisible(false);
        tabmyprofile.setVisible(false);
        tabwrite.setVisible(false);
        //tabprogress.setVisible(false);
        //tabrequest.setVisible(false);
        //tabresopns.setVisible(false);
        tabcontact.setVisible(false);
        //tabconstruction.setVisible(false);
        //tabupload.setVisible(false);
        tabkowledge.setVisible(false);
        tabfaq.setVisible(false);
        tabbplan.setVisible(false);
    }


    @Listen("onClick=#writelink")
    public void writeTo()
    {
        tabbox.setSelectedPanel(writeto);
        tabwrite.setVisible(true);
        tabrefer.setVisible(false);
        tabdispatch.setVisible(false);
        tabaccount.setVisible(false);
        tabgalery.setVisible(false);
        tabproject.setVisible(false);
        //tabflat.setVisible(false);
        tabmyprofile.setVisible(false);
        //tabprogress.setVisible(false);
        //tabrequest.setVisible(false);
        //tabresopns.setVisible(false);
        tabcontact.setVisible(false);
        tabbplan.setVisible(false);
        //tabconstruction.setVisible(false);
        //tabupload.setVisible(false);
    }
    //Track Progress
    /*@Listen("onClick=#progresslink")
    public void progressTrack()
    {
        tabbox.setSelectedPanel(trackprogress);
        tabprogress.setVisible(true);
        tabwrite.setVisible(false);
        tabrefer.setVisible(false);
        tabdispatch.setVisible(false);
        tabaccount.setVisible(false);
        //tabgalery.setVisible(false);
        tabproject.setVisible(false);
        //tabflat.setVisible(false);
        tabmyprofile.setVisible(false);
        //tabprogress.setVisible(false);
        tabrequest.setVisible(false);
        //tabresopns.setVisible(false);
        tabcontact.setVisible(false);
        tabconstruction.setVisible(false);
    }*/


    @Listen("onClick=#contactlink")
    public void contctUs()
    {
        tabbox.setSelectedPanel(contactus);
        tabcontact.setVisible(true);
        //tabresopns.setVisible(false);
        //tabrequest.setVisible(false);
        //tabprogress.setVisible(false);
        tabwrite.setVisible(false);
        tabrefer.setVisible(false);
        tabdispatch.setVisible(false);
        tabaccount.setVisible(false);
        tabgalery.setVisible(false);
        tabproject.setVisible(false);
        //tabflat.setVisible(false);
        tabmyprofile.setVisible(false);
        //tabprogress.setVisible(false);
        //tabconstruction.setVisible(false);
        //tabupload.setVisible(false);
        saveusage("contact_us");
        tabfaq.setVisible(false);
        tabkowledge.setVisible(false);
        tabbplan.setVisible(false);

    }

    @Listen("onClick=#faq")
    public void Faqcrc()
    {
        tabbox.setSelectedPanel(faqpanel);
        tabcontact.setVisible(false);
        tabwrite.setVisible(false);
        tabrefer.setVisible(false);
        tabdispatch.setVisible(false);
        tabaccount.setVisible(false);
        tabgalery.setVisible(false);
        tabproject.setVisible(false);
        tabmyprofile.setVisible(false);
        tabkowledge.setVisible(false);
        tabfaq.setVisible(true);

// faqsearch.setVisible(true); tabbplan.setVisible(false); }

    @Listen("onClick=#knowldge")
    public void Knowldgecrc()
    {
        tabbox.setSelectedPanel(knowledgepannel);
        tabcontact.setVisible(false);
        tabwrite.setVisible(false);
        tabrefer.setVisible(false);
        tabdispatch.setVisible(false);
        tabaccount.setVisible(false);
        tabgalery.setVisible(false);
        tabproject.setVisible(false);
        tabmyprofile.setVisible(false);
        tabkowledge.setVisible(true);
        tabfaq.setVisible(false);
        tabbplan.setVisible(false);
    }



    @Listen("onClick=#uploadlink")
    public void gallaryUpload()
    {
        tabbox.setSelectedPanel(galupload);
        tabusage.setVisible(false);
        tabupload.setVisible(true);
        tabfaq.setVisible(false);

// faqsearch.setVisible(false);

    }

    //Added for admin FAQ page

    /*@Listen("onClick=#faq")
    public void faq()
    {
        tabbox.setSelectedPanel(faqpanel);
        tabupload.setVisible(false);
        tabfaq.setVisible(true);
        tabusage.setVisible(false);
        faqsearch.setVisible(true);
        //createUsageGrid(CustomerCode,fromDate2,toDate2);
    }*/

    @Listen("onClick=#usagelink")
    public void usagereport()
    {
        tabbox.setSelectedPanel(usage);
        tabupload.setVisible(false);
        tabusage.setVisible(true);
        tabfaq.setVisible(false);

// faqsearch.setVisible(false); createUsageGrid(CustomerCode,fromDate2,toDate2); }

    BillingPlan billplan;

    @NotifyChange("billingPlansList2")
    @Listen("onClick = #bplanlink")
    public void billingPlan()
    {
        tabbox.setSelectedPanel(bplanpanel);

        tabcontact.setVisible(false);
        tabwrite.setVisible(false);
        tabrefer.setVisible(false);
        tabdispatch.setVisible(false);
        tabaccount.setVisible(false);
        tabgalery.setVisible(false);
        tabproject.setVisible(false);
        tabmyprofile.setVisible(false);
        tabkowledge.setVisible(false);
        tabfaq.setVisible(false);
        tabbplan.setVisible(true);
        billingPlansList2 = new BillingPlanServiceImpl().getBillinPlanList("");

        for(BillingPlan bplan : billingPlansList2)
        {
            billplan = new BillingPlan();
            System.out.println(":bplan.getBillingdate():-"+bplan.getBillingdate());
            billplan.setBillingdate(bplan.getBillingdate());
        }

        BindUtils.postGlobalCommand(null, null, "refresh", null);
        BindUtils.postNotifyChange(null, null, this, "*");


    }

    private boolean billingplantab = false;
    public boolean isBillingplantab() {
        return billingplantab;
    }
    public void setBillingplantab(boolean billingplantab) {
        this.billingplantab = billingplantab;
    }

    @Command
    @NotifyChange({"billingPlansList2","billingplantab"})
    public void billingplan()
    {
        System.out.println("Enter billingPlan Command");
        billingplantab = true;
        billingPlansList2 = new BillingPlanServiceImpl().getBillinPlanList("");
        System.out.println("billingPlansList2:-"+billingPlansList2);
        System.out.println("billingplantab:-"+billingplantab);

    }


    @GlobalCommand
    @NotifyChange("billingPlansList2")
    public void refresh(){
        System.out.println("Enter to refresh global command:-");
    }



    public List<BillingPlan> getBillingPlansList2() {
        return billingPlansList2;
    }

}

delete flag offensive retag edit

Comments

I'm refactorring the whole stuff (difficult to test cause you have a lot of unknown objects in the controller)

chillworld ( 2014-09-24 06:37:11 +0800 )edit

is this "controller" used by multiple zuls? a lot of the wirings are even not there in the zul.

chillworld ( 2014-09-24 08:07:05 +0800 )edit

yes,i am using multiple zuls

sathishk ( 2014-09-24 08:26:40 +0800 )edit

Break it down to one controller for one zul. => all the commonality you can put in an abstract class where you let your vm extends of it. (understand what I mean?)

chillworld ( 2014-09-24 15:11:07 +0800 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2014-09-24 08:39:59 +0800

chillworld gravatar image chillworld flag of Belgium
5357 4 9
https://github.com/chillw...

updated 2014-09-24 16:41:36 +0800

Hey there,

I'll don't close this question as duplicated cause you give here a complete zul and controller.
I hope this is a "middlestep" of switching MVC to MVVM cause, and I'm really sorry to say, it's crappy code.

I'll start here with some suggestions what you can do. (I'll already started refactorring the zul and code but for the moment it's almost impossible without testing cause it's just to much).

I'm not shooting you but I hope I can teach you correct way's to handle the stuff.

1. Declaration of Viewmodels:

Multiple declarations of vm's is no problem.
I have a problem with declaring a the same viewmodel multiple times.
If you need it more then once, you need to declare it higher in the tree.
Don't forget, each declaration gives you a new controller.

Secondly, when you have multiple vm's, Don't call them all "vm".
How do we know what vm you are pointing to (without searching the declaration)?

2. Labels in MVVM :

A label is normally a read only object. => Do not use @bind to set the value but @load. @bind is the shortcut for @load @save.
You just create overhead code when compiling.

3. Scoping vars.

Global variablen has to be scoped or they are package private in stead of class private.
You create the getters and setter so just add private before the declaration.

4. Unused @wire.

While I was trying to remove the the unused @wire vars, I saw that the labels where already used with the MVVM approach.
Still they are declared in your controller and do nothing.
It came worse when I was trying to search some vars like subtype.
They aren't in the zul so do you use the controller for multiple zuls or is this a forgotten deletion of refactoring?

5. The real refactoring

If you succeed in that, you could change all the @Listen by adding in the zul onClick="@command('someCommand')" in the buttons they are referring to.
You can also set the visible=@load(vm.buttonVisible) and in stead of handling the button self, handle the boolean what's in the viewmodel.
With this you will also lower the usage of the wired button till you don't use the button.
Then it's time to remove the wired button out of the class.

I think you will not get at this point easy, but if all ○6@wireand@listenare removed, it's time to remove theextends SelectorComposer<component>.
Change in the zul the declaration of controller to declaration of viewmodel (and remove all the other declarations of same viewmodel).

When you stumble across problems changing to MVVM you can ask for help(just that part of zul and controller, maybe stacktrace), I'll help with pleasure but this is a little to big to do without the possibility of testing.

Greetz chill.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2014-09-23 14:25:20 +0800

Seen: 40 times

Last updated: Sep 24 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More