
<div id="screen[index]" > 
<!-- begin:: Content -->
	<!--begin::Portlet-->
    <input type="hidden" id="txtSalesQuotationCoyId" value="-1">
	<div class="kt-portlet kt-portlet--last kt-portlet--head-lg  kt-portlet--responsive-mobile" id="kt_page_portlet">
		<div class="kt-portlet__body kt-portlet__body--fit">
			<div class="kt-section kt-section--first">
                <div class="kt-portlet__head kt-portlet__head--lg" style="min-height: 30px;padding-top:10px;padding-bottom:10px;padding-left:0px;">
                    <div class="kt-portlet__head-label col-lg-12" id="div-bu">
                        <div class="col-lg-2">
                            <h3 class="kt-portlet__head-title"><strong>Sales Quotation </strong></h3>                            
                        </div>
                        <div class="col-lg-2">
                            <select  class="form-control" id="cobSalesQuotationBU">
                            <!-- <option value="0" disabled selected>-- Select --</option> -->
                                <?php echo $this->getCompanyOption(); ?>
                            </select>
                            <span class="form-text text-muted"></span>
                        </div>
                        <div class="col-lg-4"></div>
                        <div class="col-lg-4" style="text-align:right;padding-right:95px;">
                            <button class="btn btn-primary" id="btnRetrieveSalesQuotation" onclick="javascript:filterSalesQuotation();">Retrieve</button>&nbsp;&nbsp;
                            <button class="btn btn-success" id="btnExportInvoice" onclick="javascript:openExportInvoiceModal();">Export Invoice</button>
                        </div>
                    </div>
                </div>
				<div class="kt-section__body">
                        <div class="card-body row">
                            <div class="form-group row" style="display: none;">
                                <label class="col-lg-3 col-form-label" >Sales Quotation ID:</label>
                                <div class="col-lg-3">
                                    <input type="text" class="form-control" id="txtSalesQuotationID" value="-1">
                                    <input type="text" class="form-control" id="txtSalesQuotationType">
                                    <input type="text" class="form-control" id="txtSalesQuotationGrandTotal" />
                                    <span class="form-text text-muted"></span>
                                </div>
                            </div>
                            <div class="col-lg-12" id="div-quot">
                                <div class="form-group row">
                                    <div class="col-lg-3">
                                        <div class="form-group row">
                                            <label class="col-lg-4 col-form-label" >Type</label>
                                            <div class="col-lg-6">
                                                <select class="form-control" id="cobSalesQuotationType">
                                                    <option value="">-- Quotation Type --</option>
                                                    <option value="<?php echo SalesQuotationType::Service ?>">Service</option>
                                                    <option value="<?php echo SalesQuotationType::Project ?>">Project</option>
                                                    <option value="<?php echo SalesQuotationType::Contract ?>">Contract</option>
                                                    <option value="<?php echo SalesQuotationType::Item ?>">Item</option>
                                                    <option value="<?php echo SalesQuotationType::NewSub ?>">New-Sub</option>
                                                    <option value="<?php echo SalesQuotationType::License ?>">Renew</option>
                                                </select>
                                            </div>
                                            <div class="col-lg-2" style="text-align: right;">
                                                <span class="kt-switch kt-switch--sm">
                                                    <label>
                                                        <input type="checkbox" id="chkSwitch" onchange="change_prospect();">
                                                        <span></span>
                                                    </label>
                                                </span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-lg-3">
                                        <div class="form-group row">
                                            <label class="col-lg-4 col-form-label" id="col_label">Company Name</label>
                                            <div class="col-lg-8" id="col_div">
                                                <select class="form-control" id="cobSalesQuotationCustomerCode" onchange="javascript:populateCustomerContact();">
                                                <!-- <option value="0" disabled selected>-- Select --</option> -->
                                                <?php echo $this->getCustomerOption(); ?>
                                                </select>
                                            </div>
                                            <label class="col-lg-4 col-form-label" id="pro_label" style="display:none">Prospect Name</label>
                                            <div class="col-lg-8" style="display:none" id="pro_div">
                                                <input type="text" class="form-control" id="txtSalesQuotationProspectName">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-lg-3">
                                        <div class="form-group row">
                                            <label class="col-lg-4 col-form-label">Internal #</label>
                                            <div class="col-lg-6">
                                                <input type="text" class="form-control" id="txtSalesQuotationNumberInternal" value="AUTO" disabled>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-lg-3">
                                        <div class="form-group row">
                                            <label class="col-lg-4 col-form-label">Quotation #</label>
                                            <div class="col-lg-5">
                                                <input type="text" class="form-control" id="txtSalesQuotationNumber" value="AUTO" disabled>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-12" id="div-contact">
                                <div class="form-group row">
                                    <div class="col-lg-3">
                                        <div class="form-group row">
                                            <label class="col-lg-4 col-form-label" id="col_contact_label">Contact</label>
                                            <div class="col-lg-8" id="col_contact_div">
                                                <select class="form-control" id="cobSalesQuotationContact" onchange="javascript:populateContactDetail();">
                                                    <!-- <option value="0" disabled selected>-- Select --</option> -->
                                                </select>
                                            </div>
                                            
                                            <label class="col-lg-4 col-form-label" id="pro_contact_label" style="display:none">Contact</label>
                                            <div class="col-lg-8" id="pro_contact_div" style="display:none">
                                                <input type="text" class="form-control" id="txtSalesQuotationProspectContact">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-lg-3">
                                        <div class="form-group row">
                                            <label class="col-lg-4 col-form-label">Email</label>
                                            <div class="col-lg-8">
                                                <input type="text" class="form-control" id="txtSalesQuotationEmail">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-lg-3">
                                        <div class="form-group row">
                                            <label class="col-lg-4 col-form-label">Mobile #</label>
                                            <div class="col-lg-6">
                                                <input type="text" class="form-control" id="txtSalesQuotationMobile">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-lg-3">
                                        <div class="form-group row">
                                            <label class="col-lg-4 col-form-label">Main Line </label>
                                            <div class="col-lg-5">
                                                <input type="text" class="form-control" id="txtSalesQuotationTelephone">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-12" id="div-detail">
                                <div class="form-group row">
                                    <div class="col-lg-3">
                                        <div class="form-group row">
                                            <label class="col-lg-4 col-form-label">Add. Contact</label>
                                            <div class="col-lg-8">
                                                <input type="text" class="form-control" id="txtSalesQuotationAddContact">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-lg-3">
                                        <div class="form-group row">
                                            <label class="col-lg-4 col-form-label">Quotation Title</label>
                                            <div class="col-lg-8">
                                                <input type="text" class="form-control" id="txtSalesQuotationTitle">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-lg-3">
                                        <div class="form-group row">
                                            <label class="col-lg-4 col-form-label">Currency</label>
                                            <div class="col-lg-4">
                                                <select class="form-control" id="cobSalesQuotationCurrency" onchange="changeCurrencyDetail();">
                                                <!-- <option value="" disabled selected>-- Select --</option> -->
                                                <?php echo $this->getCurrencyOption(); ?>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-lg-3">
                                        <div class="form-group row">
                                            <label class="col-lg-4 col-form-label">Preferred Inv. Date</label>
                                            <div class="col-lg-5">
                                                <input type="date" class="form-control" id="txtSalesQuotationPreferredInvoiceDate" value="<?php echo date('Y-m-d'); ?>">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-12" id="div-expected">
                                <div class="form-group row">
                                    <div class="col-lg-3">
                                        <div class="form-group row">
                                            <label class="col-lg-4 col-form-label">Probability</label>
                                            <div class="col-lg-5">
                                                <input type="text" class="form-control" id="txtSalesQuotationProbability" style="max-width: 100px;">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-lg-3">
                                        <div class="form-group row">
                                            <label class="col-lg-4 col-form-label">Exp. Accept Date</label>
                                            <div class="col-lg-5">
                                                <input type="date" class="form-control" id="txtSalesQuotationExpectedAcceptDate" value="<?php echo date('Y-m-d'); ?>">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-lg-3">
                                        <div class="form-group row">
                                            <label class="col-lg-4 col-form-label">Exp. Pay Date</label>
                                            <div class="col-lg-5">
                                                <input type="date" class="form-control" id="txtSalesQuotationExpectedPayDate" value="<?php echo date('Y-m-d'); ?>">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-lg-3">
                                        <div class="form-group row" id="div-payment">
                                            <label class="col-lg-4 col-form-label">% of Payment</label>
                                            <div class="col-lg-3">
                                                <input type="text" class="form-control" id="txtSalesQuotationPercentagePayment">
                                                <span class="form-text text-muted"></span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-12" id="div-additional">
                                <div class="form-group row">
                                    <div class="col-lg-3">
                                        <?php 
                                        if(!is_null($rowsInfo) && count($rowsInfo)>0) { 
                                            if(isset($rowsInfo)) { 
                                                if(trim($rowsInfo[0][SalesQuotationAdditionalInformationTable::C_USER_DEFINED_1]) != "") { ?>
                                                    <div class="form-group row">
                                                        <label class="col-lg-4 col-form-label" id="lblSalesQuotationUserDefined1"><?php echo $rowsInfo[0][SalesQuotationAdditionalInformationTable::C_USER_DEFINED_1]; ?></label>
                                                        <div class="col-lg-6">
                                                            <input type="text" class="form-control" id="txtSalesQuotationUserDefined1">
                                                        </div>
                                                    </div>
                                        <?php } } } ?>
                                    </div>
                                    <div class="col-lg-3">
                                        <?php 
                                        if(!is_null($rowsInfo) && count($rowsInfo)>0) { 
                                            if(isset($rowsInfo)) { 
                                                if(trim($rowsInfo[0][SalesQuotationAdditionalInformationTable::C_USER_DEFINED_2]) != "") { ?>
                                                    <div class="form-group row">
                                                        <label class="col-lg-4 col-form-label" id="lblSalesQuotationUserDefined2"><?php echo $rowsInfo[0][SalesQuotationAdditionalInformationTable::C_USER_DEFINED_2]; ?></label>
                                                        <div class="col-lg-6">
                                                            <input type="text" class="form-control" id="txtSalesQuotationUserDefined2">
                                                        </div>
                                                    </div>
                                        <?php } } } ?>
                                    </div>
                                    <div class="col-lg-3">
                                        <?php 
                                        if(!is_null($rowsInfo) && count($rowsInfo)>0) { 
                                            if(isset($rowsInfo)) { 
                                                if(trim($rowsInfo[0][SalesQuotationAdditionalInformationTable::C_USER_DEFINED_3]) != "") { ?>
                                                    <div class="form-group row">
                                                        <label class="col-lg-4 col-form-label" id="lblSalesQuotationUserDefined3"><?php echo $rowsInfo[0][SalesQuotationAdditionalInformationTable::C_USER_DEFINED_3]; ?></label>
                                                        <div class="col-lg-6">
                                                            <input type="text" class="form-control" id="txtSalesQuotationUserDefined3">
                                                        </div>
                                                    </div>
                                        <?php } } } ?>
                                    </div>
                                    <div class="col-lg-3">
                                        <?php 
                                        if(!is_null($rowsInfo) && count($rowsInfo)>0) { 
                                            if(isset($rowsInfo)) { 
                                                if(trim($rowsInfo[0][SalesQuotationAdditionalInformationTable::C_USER_DEFINED_4]) != "") { ?>
                                                    <div class="form-group row">
                                                        <label class="col-lg-4 col-form-label" id="lblSalesQuotationUserDefined4"><?php echo $rowsInfo[0][SalesQuotationAdditionalInformationTable::C_USER_DEFINED_4]; ?></label>
                                                        <div class="col-lg-5">
                                                            <input type="text" class="form-control" id="txtSalesQuotationUserDefined4">
                                                        </div>
                                                    </div>
                                        <?php } } } ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-12 kt-separator kt-separator--dashed" style="margin-top: 10px;margin-bottom: 10px;"></div>
                        <div class="col-lg-12" style="text-align:right;padding-right:130px;" id="div-buttons">
                            <button class="btn btn-secondary" id="btnClearSalesQuotation" onclick="javascript:clearSalesQuotation(true);">Clear</button>
                            <button class="btn btn-primary" id="btnSaveSalesQuotation" onclick="javascript:addRecord();">Save</button>
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <button class="btn btn-info" id="btnPreviewSalesQuotation" onclick="javascript:previewSalesQuotationPDF();">Preview</button>
                            <button class="btn btn-default" id="btnSubmitSalesQuotation" onclick="javascript:openSubmitModal();">Submit (Approval)</button>
                            <button class="btn btn-brand" id="btnApprovalSalesQuotation" onclick="javascript:openApprovalModal(0,'');">Action (Approval)</button>
                            <button class="btn btn-warning" id="btnIssueSalesQuotation">Issue (Customer)</button>
                            <button class="btn btn-danger" id="btnReviseSalesQuotation">Revise (Customer)</button>
                            <button class="btn btn-success" id="btnAcceptSalesQuotation">Accepted</button>
                            <button class="btn btn-dark" id="btnClosedSalesQuotation" onclick="javascript:closedSalesQuotation();">Close</button>
                            <button class="btn btn-light" id="btnProformaInvoiceSalesQuotation" onclick="javascript:openModalInvoice(0);">Proforma Invoice</button>
                        </div>
                        <div class="col-lg-12 kt-separator kt-separator--dashed" style="margin-top: 10px;margin-bottom: 10px;"></div>  
                        <div class="col-lg-12">
                            <!-- Code Tab Here -->
                            <ul class="nav nav-tabs nav-tabs-line nav-tabs-line-brand" id="myTab" role="tablist">
                                <li class="nav-item">
                                    <a class="nav-link active" id="general-tab" data-toggle="tab" 
                                        style="padding-top:0"
                                        href="#general">
                                        <i class="flaticon-edit-1"></i>Issue To Solve
                                    </a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" id="items-tab" data-toggle="tab" 
                                        style="padding-top:0"
                                        href="#items" aria-controls="items">
                                        <i class="flaticon2-box-1"></i>Items
                                    </a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" id="mands-tab" data-toggle="tab" 
                                        style="padding-top:0"
                                        href="#mands" aria-controls="mands">
                                        <i class="flaticon-support"></i>M & S
                                    </a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" id="projectplan-tab" data-toggle="tab" 
                                        style="padding-top:0"
                                        href="#projectplan" aria-controls="projectplan">
                                        <i class="flaticon-clock-2"></i>Project Plan
                                    </a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" id="cover-tab" data-toggle="tab" 
                                        style="padding-top:0"
                                        href="#cover" aria-controls="cover">
                                        <i class="flaticon-interface-11"></i>Cover
                                    </a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" id="footer-tab" data-toggle="tab" 
                                        style="padding-top:0"
                                        href="#footer" aria-controls="footer">
                                        <i class="flaticon-interface-10"></i>Footer
                                    </a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" id="appendix-tab" data-toggle="tab" 
                                        style="padding-top:0"
                                        href="#appendix" aria-controls="appendix">
                                        <i class="flaticon-notes"></i>Appendix
                                    </a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" id="attachment-tab" data-toggle="tab" 
                                        style="padding-top:0"
                                        href="#attachment" aria-controls="attachment">
                                        <i class="flaticon-attachment"></i>Attachment
                                    </a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" id="final-tab" data-toggle="tab" 
                                        style="padding-top:0"
                                        href="#final" aria-controls="final">
                                        <i class="flaticon-interface-9"></i>Final
                                    </a>
                                </li>
                            </ul>
                            <div class="tab-content" id="myTabContent">
                                <div class="tab-pane fade active show" id="general" role="tabpanel" aria-labelledby="general-tab">
                                    <?php  include (PATH_CODE . "views/portal/salesquotation/tabs/issue.php") ; ?>
                                </div>
                                <div class="tab-pane fade" id="items" role="tabpanel" aria-labelledby="items-tab">
                                    <?php  include (PATH_CODE . "views/portal/salesquotation/tabs/items.php") ; ?>
                                </div>
                                <div class="tab-pane fade" id="mands" role="tabpanel" aria-labelledby="mands-tab">
                                    <?php  include (PATH_CODE . "views/portal/salesquotation/tabs/maintenance.php") ; ?>
                                </div>
                                <div class="tab-pane fade" id="projectplan" role="tabpanel" aria-labelledby="projectplan-tab">
                                    <?php  include (PATH_CODE . "views/portal/salesquotation/tabs/projectplan.php") ; ?>
                                </div>
                                <div class="tab-pane fade" id="cover" role="tabpanel" aria-labelledby="cover-tab">
                                    <?php  include (PATH_CODE . "views/portal/salesquotation/tabs/cover.php") ; ?>
                                </div>
                                <div class="tab-pane fade" id="footer" role="tabpanel" aria-labelledby="footer-tab">
                                    <?php  include (PATH_CODE . "views/portal/salesquotation/tabs/footer.php") ; ?>
                                </div>
                                <div class="tab-pane fade" id="appendix" role="tabpanel" aria-labelledby="appendix-tab">
                                    <?php  include (PATH_CODE . "views/portal/salesquotation/tabs/appendix.php") ; ?>
                                </div>
                                <div class="tab-pane fade" id="attachment" role="tabpanel" aria-labelledby="attachment-tab">
                                    <?php  include (PATH_CODE . "views/portal/salesquotation/tabs/attachment.php") ; ?>
                                </div>
                                <div class="tab-pane fade" id="final" role="tabpanel" aria-labelledby="final-tab">
                                </div>
                            </div>
                        </div>
                    </div>
				</div>
			</div>
		</div>
		<div class="kt-portlet__footer" id="carFooter" >
            
		</div>
	</div>
	<!--end::Portlet-->

    <!-- Sales Quotation Retrieve Modal HTML -->
    <div class="modal fade" id="showSalesQuotationView" tabindex="-1" aria-modal="true" role="dialog">
        <div class="modal-dialog modal-dialog-scrollable modal-xl" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="showSalesQuotationLabel">Sales Quotation List</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <i aria-hidden="true" class="ki ki-close"></i>
                    </button>
                </div>
                <div class="modal-body">
                    <div id="modalshowSalesQuotationContent">
                        <div class="form-group row form-group-marginless">
                            <label class="col-lg-1 col-form-label" id="coyLabel">Company</label>
                            <div class="col-lg-3" id="coyDiv">
                                <select class="form-control" id="cmbSalesQuotationCoyFilter">
                                    <?php echo $this->getCustomerOptionFilter(); ?>
                                </select>
                            </div>
                            <label class="col-lg-1 col-form-label" id="prospectLabel" style="display:none">Prospect</label>
                            <div class="col-lg-3" style="display:none" id="prospectDiv">
                                <input type="text" class="form-control" id="txtSalesQuotationProspectFilter">
                                <span class="form-text text-muted"></span>
                            </div>
                            <div class="col-2" style="max-width: 60px;max-height: 40px;">
                                <span class="kt-switch kt-switch--sm" style="width: 60px;height: 40px;">
                                    <label>
                                        <input type="checkbox" id="chkSalesQuotationOptFilter" onchange="change_option('');">
                                        <span></span>
                                    </label>
                                </span>
                            </div>
                            <label class="col-lg-1 col-form-label" style="max-width: 80px;">Status</label>
                            <div class="col-2" style="max-width: 150px;">
                                <select class="form-control" id="cmbSalesQuotationStatusFilter"><?php echo $this->getOptionSalesQuotationStatus(); ?></select>
                            </div>
                            <div class="col-2" style="max-width: 150px;">
                                <select class="form-control" id="cmbSalesQuotationFilterDate">
                                <option value="0">Create Date</option>
                                <option value="5">Preferred Inv. Date</option>
                                <option value="1">Issue Date</option>
                                <option value="2">Revise Date</option>
                                <option value="9">Exp. Accept Date</option>
                                <option value="10">Exp. Pay Date</option>
                                <option value="3">Accept Date</option>
                                <option value="4">Close Date</option>
                                <option value="7">Submit Date</option>
                                <option value="8">Approval Date</option>
                                <option value="6">Invoice Date</option>
                                </select>
                            </div>
                            <div class="col-2" style="max-width: 180px;">
                                <div class="input-group date">
                                    <input type="text" class="form-control" id="txtFilterSalesQuotationFromDate">
                                    <div class="input-group-append">
                                        <span class="input-group-text">
                                            <i class="la la-calendar-check-o"></i>
                                        </span>
                                    </div>
                                </div>
                            </div>
                            <label class="col-form-label">To</label>
                            <div class="col-2" style="max-width: 180px;">
                                <div class="input-group date">
                                    <input type="text" class="form-control" id="txtFilterSalesQuotationToDate">
                                    <div class="input-group-append">
                                        <span class="input-group-text">
                                            <i class="la la-calendar-check-o"></i>
                                        </span>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-1">
                                <button type="button" class="btn btn-default" id="btnFilterSalesQuotation" onclick="javascript:filterSalesQuotation();"><i class="fa fa-filter"></i> Filter </button>
                            </div>
                        </div>
                        <br>
                        <!--begin: Datatable -->
                        <div class="kt-datatable kt-datatable--default kt-datatable--brand kt-datatable--loaded">
                            <table class="kt-datatable__table" id="jobquotation_table_data">
                                <thead class="kt-datatable__head">
                                    <tr class="dnd-moved kt-datatable__row" style="left: 0px;">
                                        <th class="kt-datatable__cell" style="display: none;">
                                            ID
                                        </th>
                                        <th width="5%" class="kt-datatable__cell">
                                            BU
                                        </th>
                                        <th width="12%" class="kt-datatable__cell">
                                            Internal #
                                        </th>
                                        <th width="12%" class="kt-datatable__cell">
                                            Quotation #
                                        </th>
                                        <th width="7%" class="kt-datatable__cell">
                                            Type
                                        </th>
                                        <th width="25%" class="kt-datatable__cell">
                                            Company/Prospect
                                        </th>
                                        <th width="12%" class="kt-datatable__cell">
                                            Contact Name
                                        </th>
                                        <th width="20%" class="kt-datatable__cell">
                                            Title
                                        </th>
                                        <!-- <th width="15%" class="kt-datatable__cell">
                                            Email
                                        </th>
                                        <th width="8%" class="kt-datatable__cell">
                                            Mobile #
                                        </th> -->
                                        <th width="7%" class="kt-datatable__cell" style="text-align: center;">
                                            Currency
                                        </th>
                                        <th width="7%" class="kt-datatable__cell">
                                            Status
                                        </th>
                                        <th width="15%" class="kt-datatable__cell">
                                            Proforma Invoice
                                        </th>
                                        <th width="15%" class="kt-datatable__cell">
                                            Date
                                        </th>
                                        <th width="1%" class="kt-datatable__cell">&nbsp;</th>
										<th width="1%" class="kt-datatable__cell">&nbsp;</th>
										<th width="1%" class="kt-datatable__cell">&nbsp;</th>
										<th class="kt-datatable__cell">&nbsp;</th>
                                    </tr>
                                </thead>
                                <tbody class="kt-datatable__body" id="sales-quotation-list-table">
                                </tbody>
                            </table>                            
                        </div>
                        <!--end: Datatable -->
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary font-weight-bold" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>
    <!--End Modal -->

    <!-- Export Invoice Modal -->
    <div class="modal fade" id="exportInvoiceView" tabindex="-1" aria-modal="true" role="dialog">
        <div class="modal-dialog modal-dialog-scrollable modal-xl" role="document" style="width: 1200px;">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">Export Invoice</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <i aria-hidden="true" class="ki ki-close"></i>
                    </button>
                </div>
                <div class="modal-body">
                    <div class="form-group row form-group-marginless">
                        <!-- <label class="col-lg-1 col-form-label" id="coyLabelExport">Company</label>
                        <div class="col-lg-3" id="coyDivExport">
                            <select class="form-control" id="cmbExportInvoiceCoyFilter">
                                <?php //echo $this->getCustomerOptionFilter(); ?>
                            </select>
                        </div>
                        <label class="col-lg-1 col-form-label" id="prospectLabelExport" style="display:none">Prospect</label>
                        <div class="col-lg-3" style="display:none" id="prospectDivExport">
                            <input type="text" class="form-control" id="txtExportInvoiceProspectFilter">
                            <span class="form-text text-muted"></span>
                        </div>
                        <div class="col-2" style="max-width: 60px;max-height: 40px;">
                            <span class="kt-switch kt-switch--sm" style="width: 60px;height: 40px;">
                                <label>
                                    <input type="checkbox" id="chkExportInvoiceOptFilter" onchange="change_option('export');">
                                    <span></span>
                                </label>
                            </span>
                        </div> -->
                        <div class="col-2" style="max-width: 150px;">
                            <select class="form-control" id="cmbExportInvoiceDateFilter">
                            <option value="6">Invoice Date</option>
                            </select>
                        </div>
                        <div class="col-2" style="max-width: 180px;">
                            <div class="input-group date">
                                <input type="text" class="form-control" id="txtExportInvoiceFromDateFilter">
                                <div class="input-group-append">
                                    <span class="input-group-text">
                                        <i class="la la-calendar-check-o"></i>
                                    </span>
                                </div>
                            </div>
                        </div>
                        <label class="col-form-label">To</label>
                        <div class="col-2" style="max-width: 180px;">
                            <div class="input-group date">
                                <input type="text" class="form-control" id="txtExportInvoiceToDateFilter">
                                <div class="input-group-append">
                                    <span class="input-group-text">
                                        <i class="la la-calendar-check-o"></i>
                                    </span>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-2">
                            <button type="button" class="btn btn-default" id="btnExportInvoiceFilter" onclick="javascript:filterExportInvoice();"><i class="fa fa-filter"></i> Filter </button>
                        </div>
                    </div>
                    <br>
                    <!--begin: Datatable -->
                    <div class="kt-datatable kt-datatable--default kt-datatable--brand kt-datatable--loaded">
                        <table class="kt-datatable__table" id="exportinvoice_table_data">
                            <thead class="kt-datatable__head">
                                <tr class="dnd-moved kt-datatable__row" style="left: 0px;">
                                    <th class="kt-datatable__cell" style="display: none;">
                                        ID
                                    </th>
                                    <th width="8%" class="kt-datatable__cell">
                                        BU
                                    </th>
                                    <th width="35%" class="kt-datatable__cell">
                                        Company/Prospect
                                    </th>
                                    <th width="15%" class="kt-datatable__cell">
                                        Quotation #
                                    </th>
                                    <th width="7%" class="kt-datatable__cell" style="text-align: center;">
                                        Currency
                                    </th>
                                    <th width="15%" class="kt-datatable__cell" style="text-align: right;">
                                        Total Amount
                                    </th>
                                    <th width="15%" class="kt-datatable__cell" style="text-align: right;">
                                        Payable Amount
                                    </th>
                                    <th width="1%" class="kt-datatable__cell">&nbsp;</th>
                                    <th width="1%" class="kt-datatable__cell">&nbsp;</th>
                                    <th width="1%" class="kt-datatable__cell">&nbsp;</th>
                                    <th class="kt-datatable__cell">&nbsp;</th>
                                </tr>
                            </thead>
                            <tbody class="kt-datatable__body" id="export-invoice-list-table">
                            </tbody>
                        </table>                            
                    </div>
                    <!--end: Datatable -->
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary font-weight-bold" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-success font-weight-bold" data-dismiss="modal" onclick="javascript:exportInvoiceExcel();">Export Excel</button>
                </div>
            </div>
        </div>
    </div>
    <!--End Modal -->

	<script>
       
    <?php  include (PATH_CODE . "js/portal/salesquotation/item.js") ; ?>
    <?php  include (PATH_CODE . "js/portal/salesquotation/maintenancesupport.js") ; ?>
    <?php  include (PATH_CODE . "js/portal/salesquotation/appendix.js") ; ?>
    <?php  include (PATH_CODE . "js/portal/salesquotation/projectplan.js") ; ?>
    <?php  include (PATH_CODE . "js/portal/salesquotation/cover.js") ; ?>
    <?php  include (PATH_CODE . "js/portal/salesquotation/attachment.js") ; ?>
    <?php  include (PATH_CODE . "js/portal/salesquotation/invoice.js") ; ?>

    function change_prospect() {
        if(!$("#chkSwitch").is(":checked")){
           
            $('#col_div').show();
            $('#col_label').show();
            $('#col_contact_div').show();
            $('#col_contact_label').show();
         
            $('#pro_div').hide();
            $('#pro_label').hide();
            $('#pro_contact_div').hide();
            $('#pro_contact_label').hide();
        }else{
            
            $('#col_div').hide();
            $('#col_label').hide();
            $('#col_contact_div').hide();
            $('#col_contact_label').hide();

            $('#pro_div').show();
            $('#pro_label').show();
            $('#pro_contact_div').show();
            $('#pro_contact_label').show();
        }
        
        $('#txtSalesQuotationProspectName').val('');
        $('#txtSalesQuotationProspectContact').val('');
        $('#txtSalesQuotationEmail').val('');
        $('#txtSalesQuotationMobile').val('');
        $('#txtSalesQuotationTelephone').val('');

    }

    function change_option(mode) {
        if(mode == '') {
            if(!$("#chkSalesQuotationOptFilter").is(":checked")){
                $('#coyDiv').show();
                $('#coyLabel').show();
            
                $('#prospectDiv').hide();
                $('#prospectLabel').hide();
                $('#txtSalesQuotationProspectFilter').val("");
            }else{
                $('#coyDiv').hide();
                $('#coyLabel').hide();
                $('#cmbSalesQuotationCoyFilter').val(0);

                $('#prospectDiv').show();
                $('#prospectLabel').show();
            }
            filterSalesQuotation();
        } else {
            if(!$("#chkExportInvoiceOptFilter").is(":checked")){
                $('#coyDivExport').show();
                $('#coyLabelExport').show();
            
                $('#prospectDivExport').hide();
                $('#prospectLabelExport').hide();
                $('#txtExportInvoiceProspectFilter').val("");
            }else{
                $('#coyDivExport').hide();
                $('#coyLabelExport').hide();
                $('#cmbExportInvoiceCoyFilter').val(0);

                $('#prospectDivExport').show();
                $('#prospectLabelExport').show();
            }
            filterExportInvoice();
        }
    }
    </script>
<!-- end:: Content -->
</div>
<div id="screen[index]a">
</div>

<!-- save template pop up Appendix Modal HTML -->
<div class="modal fade" id="SaveAppendixTemplateConfirmationView" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="modalSaveAppendixTemplateConfirmationTitle">Template</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <div class="col-md-9">
                        <input data-switch="true" type="checkbox" checked="checked" id="chkAppendixTempOption" data-on-text="New" data-off-text="Update" onchange="changeAppendixTempOption()">
                        <input type="text" class="form-control" id="txtChkAppendixTempOption" style="display: none;">
                    </div>
                    <br>
                    <div class="col-md-12" id="divAppendixTemplateName">
                        <input type="text" class="form-control" id="AppendixTemplateName" placeholder="Template Name...">
                    </div>
                    <div class="col-md-12" id="divAppendixTemplateList" style="display: none;">
                        <select class="form-control" name="AppendixTemplateList" id="AppendixTemplateList"></select>
                        <!-- <input style="margin-top:10px;" type="text" class="form-control" id="appendixTemplateNewName" placeholder="New Name..."> -->
                    </div>
                </div>
                <div class="modal-footer">
                    <div id="modalSaveAppendixTemplateConfirmationButton">
                   </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Load template pop up Appendix Modal HTML -->
    <div class="modal fade" id="LoadAppendixTemplateConfirmationView" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="modalLoadAppendixTemplateConfirmationTitle">Template</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    </button>
                </div>
                <div class="modal-body">
                    <div class="col-md-12" id="modalLoadAppendixTemplateConfirmationContent">
                        <select class="form-control" name="AppendixTemplateLoad" id="AppendixTemplateLoad"></select>
                    </div>
                </div>
                <div class="modal-footer">
                    <div id="modalLoadAppendixTemplateConfirmationButton">
                   </div>
                </div>
            </div>
        </div>
    </div>

    <!-- ============================================= -->

    <!-- save template pop up Project Plan Modal HTML -->
    <div class="modal fade" id="SaveProjectPlanTemplateConfirmationView" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="modalSaveProjectPlanTemplateConfirmationTitle">Template</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <div class="col-md-9">
                        <input data-switch="true" type="checkbox" checked="checked" id="chkProjectPlanTempOption" data-on-text="New" data-off-text="Update" onchange="changeProjectPlanTempOption()">
                        <input type="text" class="form-control" id="txtChkProjectPlanTempOption" style="display: none;">
                    </div>
                    <br>
                    <div class="col-md-12" id="divProjectPlanTemplateName">
                        <input type="text" class="form-control" id="ProjectPlanTemplateName" placeholder="Template Name...">
                    </div>
                    <div class="col-md-12" id="divProjectPlanTemplateList" style="display: none;">
                        <select class="form-control" name="ProjectPlanTemplateList" id="ProjectPlanTemplateList"></select>
                        <!-- <input style="margin-top:10px;" type="text" class="form-control" id="projectPlanTemplateNewName" placeholder="New Name..."> -->
                    </div>
                </div>
                <div class="modal-footer">
                    <div id="modalSaveProjectPlanTemplateConfirmationButton">
                   </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Load template pop up Project Plan Modal HTML -->
    <div class="modal fade" id="LoadProjectPlanTemplateConfirmationView" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="modalLoadProjectPlanTemplateConfirmationTitle">Template</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    </button>
                </div>
                <div class="modal-body">
                    <div class="col-md-12" id="modalLoadProjectPlanTemplateConfirmationContent">
                        <select class="form-control" name="ProjectPlanTemplateLoad" id="ProjectPlanTemplateLoad"></select>
                    </div>
                </div>
                <div class="modal-footer">
                    <div id="modalLoadProjectPlanTemplateConfirmationButton">
                   </div>
                </div>
            </div>
        </div>
    </div>

    <!-- ============================================= -->

    <!-- save template pop up Maintenance & Support Modal HTML -->
    <div class="modal fade" id="SaveMaintenanceTemplateConfirmationView" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="modalSaveMaintenanceTemplateConfirmationTitle">Template</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <div class="col-md-9">
                        <input data-switch="true" type="checkbox" checked="checked" id="chkMaintenanceTempOption" data-on-text="New" data-off-text="Update" onchange="changeMaintenanceTempOption()">
                        <input type="text" class="form-control" id="txtChkMaintenanceTempOption" style="display: none;">
                    </div>
                    <br>
                    <div class="col-md-12" id="divMaintenanceTemplateName">
                        <input type="text" class="form-control" id="MaintenanceTemplateName" placeholder="Template Name...">
                    </div>
                    <div class="col-md-12" id="divMaintenanceTemplateList" style="display: none;">
                        <select class="form-control" name="MaintenanceTemplateList" id="MaintenanceTemplateList"></select>
                        <!-- <input style="margin-top:10px;" type="text" class="form-control" id="maintenanceTemplateNewName" placeholder="New Name..."> -->
                    </div>
                </div>
                <div class="modal-footer">
                    <div id="modalSaveMaintenanceTemplateConfirmationButton">
                   </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Load template pop up Maintenance & Support Modal HTML -->
    <div class="modal fade" id="LoadMaintenanceTemplateConfirmationView" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="modalLoadMaintenanceTemplateConfirmationTitle">Template</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    </button>
                </div>
                <div class="modal-body">
                    <div class="col-md-12" id="modalLoadMaintenanceTemplateConfirmationContent">
                        <select class="form-control" name="MaintenanceTemplateLoad" id="MaintenanceTemplateLoad"></select>
                    </div>
                </div>
                <div class="modal-footer">
                    <div id="modalLoadMaintenanceTemplateConfirmationButton">
                   </div>
                </div>
            </div>
        </div>
    </div>

    <!-- ============================================= -->

    <!-- save template pop up Cover Modal HTML -->
    <div class="modal fade" id="SaveCoverTemplateConfirmationView" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="modalSaveCoverTemplateConfirmationTitle">Template</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <div class="col-md-9">
                        <input data-switch="true" type="checkbox" checked="checked" id="chkCoverTempOption" data-on-text="New" data-off-text="Update" onchange="changeCoverTempOption()">
                        <input type="text" class="form-control" id="txtChkCoverTempOption" style="display: none;">
                    </div>
                    <br>
                    <div class="col-md-12" id="divCoverTemplateName">
                        <input type="text" class="form-control" id="CoverTemplateName" placeholder="Template Name...">
                    </div>
                    <div class="col-md-12" id="divCoverTemplateList" style="display: none;">
                        <select class="form-control" name="CoverTemplateList" id="CoverTemplateList"></select>
                        <!-- <input style="margin-top:10px;" type="text" class="form-control" id="coverTemplateNewName" placeholder="New Name..."> -->
                    </div>
                </div>
                <div class="modal-footer">
                    <div id="modalSaveCoverTemplateConfirmationButton">
                   </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Load template pop up Cover Modal HTML -->
    <div class="modal fade" id="LoadCoverTemplateConfirmationView" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="modalLoadCoverTemplateConfirmationTitle">Template</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    </button>
                </div>
                <div class="modal-body">
                    <div class="col-md-12" id="modalLoadCoverTemplateConfirmationContent">
                        <select class="form-control" name="CoverTemplateLoad" id="CoverTemplateLoad"></select>
                    </div>
                </div>
                <div class="modal-footer">
                    <div id="modalLoadCoverTemplateConfirmationButton">
                   </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Issue Sales Quotation Modal -->
    <div class="modal fade" id="issueSalesQuotationModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="modalIssueSalesQuotationModalTitle">Issue</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="flaticon-times"></i></button>
                </div>
                <div class="modal-body">
                    <div id="modalIssueSalesQuotationModalContent">
                        <div class="row" style="margin-left:5%;margin-right:5%;margin-bottom:5px;">
                            <label  for="" class="col-md-3 control-label">Contact Name</label>
                            <div class="col-md-9" >
                                <p id="labelSalesQuotationContactName"></p>
                            </div>
                        </div>
                        <div class="row" style="margin-left:5%;margin-right:5%;margin-bottom:5px;">
                            <label  for="" class="col-md-3 control-label" style="padding-top:7px;">Email To</label>
                            <div class="col-md-9" >
                                <input type="text" class="form-control" id="salesQuotationIssueTo">
                            </div>
                        </div>
                        <div class="row" style="margin-left:5%;margin-right:5%;margin-bottom:5px;">
                            <label  for="" class="col-md-3 control-label" style="padding-top:7px;">Email CC</label>
                            <div class="col-md-9" >
                                <input type="text" class="form-control" id="salesQuotationIssueCC">
                            </div>
                        </div>
                        <div class="row" style="margin-left:5%;margin-right:5%;">
                            <textarea data-provide="markdown" class="form-control" name="markdown" id="salesQuotationIssueRemarks" cols="30" rows="10"></textarea>
                        </div>
                    </div>
                    <br><br>
                    <div id="modaluploadDocSalesQuotationContent">
                    </div>
                </div>
                <div class="modal-footer">
                    <div id="salesQuotationIssueModalButtonContent">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
                        <button type="button" id="btnSendIssueSalesQuotation" class="btn btn-success" onclick="sendIssueSalesQuotation()">Send Email</button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Revise Sales Quotation Modal -->
    <div class="modal fade" id="reviseSalesQuotationModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="modalReviseSalesQuotationModalTitle">Revise</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="flaticon-times"></i></button>
                </div>
                <div class="modal-body">
                    <div id="modalReviseSalesQuotationModalContent">
                        <div class="row" style="margin-left:5%;margin-right:5%;margin-bottom:5px;">
                            <label  for="" class="col-md-3 control-label">Contact Name</label>
                            <div class="col-md-9" >
                                <p id="labelSalesQuotationName"></p>
                            </div>
                        </div>
                        <div class="row" style="margin-left:5%;margin-right:5%;margin-bottom:5px;">
                            <label  for="" class="col-md-3 control-label" style="padding-top:7px;">Email To</label>
                            <div class="col-md-9" >
                                <input type="text" class="form-control" id="salesQuotationReviseTo">
                            </div>
                        </div>
                        <div class="row" style="margin-left:5%;margin-right:5%;margin-bottom:5px;">
                            <label  for="" class="col-md-3 control-label" style="padding-top:7px;">Email CC</label>
                            <div class="col-md-9" >
                                <input type="text" class="form-control" id="salesQuotationReviseCC">
                            </div>
                        </div>
                        <div class="row" style="margin-left:5%;margin-right:5%;">
                            <textarea data-provide="markdown" class="form-control" name="markdown" id="salesQuotationReviseRemarks" cols="30" rows="10"></textarea>
                        </div>
                    </div>
                    <br><br>
                    <div id="modaluploadDocReviseSalesQuotationContent">
                    </div>
                </div>
                <div class="modal-footer">
                    <div id="salesQuotationReviseModalButtonContent">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
                        <button type="button" id="btnSendReviseSalesQuotation" class="btn btn-success" onclick="sendReviseSalesQuotation()">Send Email</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- List of Revise Sales Quotation Modal -->
    <div class="modal fade" id="reviseListSalesQuotationModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-md" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="modalReviseListSalesQuotationModalTitle">Sales Quotation Revision List</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="flaticon-times"></i></button>
                </div>
                <div class="modal-body">
                    <div id="modalReviseListSalesQuotationModalContent">
                        <select class="form-control" id="cmbReviseListSalesQuotation">
                        </select>
                    </div>
                </div>
                <div class="modal-footer">
                    <div id="salesQuotationReviseListModalButtonContent">
                        <button type="button" class="btn btn-secondary" style="min-height: 58px;min-width: 80px;" data-dismiss="modal">Cancel</button>
                        <button type="button" id="btnEditReviseSalesQuotation" class="btn btn-success" style="min-height: 58px;min-width: 80px;" onclick="javascript:editSalesQuotation()">Edit/View</button>
                        <button type="button" id="btnCopySalesQuotation" class="btn btn-default" style="min-height: 58px;min-width: 80px;" onclick="javascript:copySalesQuotation()">Copy</button>
                        <button type="button" id="btnNewReviseSalesQuotation" class="btn btn-primary" style="min-height: 58px;min-width: 80px;" onclick="javascript:updateRevise(0)">Internal<br>Revision</button>
                        <button type="button" id="btnCustomerReviseSalesQuotation" class="btn btn-primary" style="min-height: 58px;min-width: 80px;" onclick="javascript:updateRevise(1)">Customer<br>Revision</button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Submit Sales Quotation Modal -->
    <div class="modal fade" id="submitSalesQuotationModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="modalSubmitSalesQuotationModalTitle">Submit (Approval)</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="flaticon-times"></i></button>
                </div>
                <div class="modal-body">
                    <div id="modalSubmitSalesQuotationModalContent">
                        <div class="row" style="margin-left:5%;margin-right:5%;margin-bottom:5px;">
                            <label  for="" class="col-md-3 control-label" style="padding-top:7px;">Approver</label>
                            <div class="col-md-5" >
                                <select class="form-control" id="cobSalesQuotationApprover" onchange="populateUserEmail();"><?php echo $this->getUser(); ?></select>
                                <select class="form-control" id="cobSalesQuotationApproverEmail" style="display:none;"><?php echo $this->getUserEmail(); ?></select>
                            </div>
                        </div>
                        <div class="row" style="margin-left:5%;margin-right:5%;margin-bottom:5px;">
                            <label  for="" class="col-md-3 control-label" style="padding-top:7px;">Email To</label>
                            <div class="col-md-9" >
                                <input type="text" class="form-control" id="salesQuotationSubmitTo">
                            </div>
                        </div>
                        <div class="row" style="margin-left:5%;margin-right:5%;margin-bottom:5px;">
                            <label  for="" class="col-md-3 control-label" style="padding-top:7px;">Email CC</label>
                            <div class="col-md-9" >
                                <input type="text" class="form-control" id="salesQuotationSubmitCC">
                            </div>
                        </div>
                        <div class="row" style="margin-left:5%;margin-right:5%;">
                            <textarea data-provide="markdown" class="form-control" name="markdown" id="salesQuotationSubmitRemarks" cols="30" rows="10"></textarea>
                        </div>
                    </div>
                    <br><br>
                    <div id="modaluploadDocSubmitSalesQuotationContent">
                        <!-- <div>
                            <h4>Quotation Attachment</h4>
                        </div>

                        <div class="col-lg-12" style="padding-left:0px;">
                            <a style="cursor:pointer;color: #5867dd;text-decoration: underline;" id="btnSubmitSalesQuotationPreview" onclick="javascript:previewSalesQuotationPDF();">                                
                            </a>
                        </div> -->
                    </div>
                </div>
                <div class="modal-footer">
                    <div id="salesQuotationSubmitModalButtonContent">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
                        <button type="button" id="btnSendSubmitSalesQuotation" class="btn btn-success" onclick="submitSalesQuotation()">Confirm</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
        
        <!-- Proforma Invoice Sales Quotation Modal -->
        <div class="modal fade" id="invoiceModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
            <div class="modal-dialog modal-lg" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">Generate Invoice</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="flaticon-times"></i></button>
                    </div>
                    <div class="modal-body">
                        <div>
                            <div class="row" style="margin-left:5%;margin-right:5%;margin-bottom:5px;">
                                <label  for="" class="col-md-3 control-label" style="padding-top:7px;">Invoice Number: </label>
                                <div class="col-md-4" >
                                    <input type="text" class="form-control" id="txtInvoiceNumber" disabled />
                                    <input type="hidden" class="form-control" id="txtInvoiceRunningNumber"/>
                                </div>
                                <div class="col-md-3" style="padding-top:10px;">
                                    <input type="checkbox" id="txtInvoiceOverride" onchange="overriedInvoiceNumber(this);"> Override
                                </div>
                            </div>
                            <div class="row" style="margin-left:5%;margin-right:5%;margin-bottom:5px;">
                                <label  for="" class="col-md-3 control-label" style="padding-top:7px;">Invoice Title: </label>
                                <div class="col-md-4" >
                                    <select class="form-control" id="cobInvoiceTitle">
                                        <!-- <option value="P">Proforma Invoice</option>
                                        <option value="A">Tax Invoice</option> -->
                                        <?php echo $this->getInvoiceTitleOption(); ?>
                                    </select>
                                </div>
                            </div>
                            <div class="row" style="margin-left:5%;margin-right:5%;margin-bottom:5px;">
                                <label  for="" class="col-md-3 control-label" style="padding-top:7px;">Type: </label>
                                <div class="col-md-4" >
                                    <select class="form-control" id="cobInvoiceType" onchange="changeInvoiceType(this);">
                                        <option value="P">Percentage</option>
                                        <option value="A">Amount</option>
                                    </select>
                                </div>
                                <label  for="" class="col-md-2 control-label" style="padding-top:7px;">Value: </label>
                                <div class="col-md-3" >
                                    <input type="text" class="form-control" id="txtInvoiceValue" style="text-align: right;" placeholder="0" onchange="changeInvoiceValue(this);" />
                                </div>
                            </div>
                            <div class="row" style="margin-left:5%;margin-right:5%;margin-bottom:5px;">
                                <label  for="" class="col-md-3 control-label" style="padding-top:7px;">Customer Reference: </label>
                                <div class="col-md-4" >
                                    <input type="text" class="form-control" id="txtInvoiceCustomerReference" />
                                </div>
                                <label  for="" class="col-md-2 control-label" style="padding-top:7px;white-space:nowrap;">Payment Terms: </label>
                                <div class="col-md-3" >
                                    <select class="form-control" id="cobInvoicePaymentTerms">
                                        <!-- <option value="" disabled selected>-- Payment Terms --</option> -->
                                        <?php echo $this->getPaymentTermsOption(); ?>
                                    </select>
                                </div>
                            </div>
                            <div class="row" style="margin-left:5%;margin-right:5%;">
                                <label  for="" class="col-md-3 control-label" style="padding-top:7px;">Remarks: </label>
                                <div class="col-md-9" >
                                    <textarea data-provide="markdown" class="form-control" name="markdown" id="txtInvoiceRemark" cols="10" rows="3"></textarea>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <div>
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
                            <button type="button" id="btnGenerateInvoice" class="btn btn-success" onclick="generateInvoice();">Generate Invoice</button>
                            <button type="button" id="btnRetrieveInvoice" class="btn btn-success" onclick="retrieveInvoice();">Retrieve Invoice</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--end::Modal-->

<script>
  $(document).ready(function() {
      
    var claimDayLast = 30;
    var date = new Date();
    var firstDay = new Date();
    var lastDay = new Date();
    var todayDate = new Date();
    var startDate = new Date(new Date().setDate(todayDate.getDate()-claimDayLast));
    firstDay.setFullYear(date.getFullYear(), date.getMonth(), 1);
    lastDay.setFullYear(date.getFullYear(), date.getMonth() + 1, 0);

    var dteopt = {
        // todayHighlight: true,
        orientation: "bottom left",
        autoclose: true,
        format: 'dd/mm/yyyy',
        templates: {
            leftArrow: '<i class="la la-angle-left"></i>',
            rightArrow: '<i class="la la-angle-right"></i>'
        }
    }

    $("#txtFilterSalesQuotationFromDate").datepicker(dteopt) ;
    $("#txtFilterSalesQuotationToDate").datepicker(dteopt) ;
    
    // // last xx days
    $('#txtFilterSalesQuotationFromDate').datepicker('setDate', (startDate.getDate() <= 9 ? "0" + startDate.getDate() : startDate.getDate()) + "/" + (startDate.getMonth()+1 <= 9 ? "0" + (startDate.getMonth()+1) : (startDate.getMonth()+1) ) + "/" + startDate.getFullYear());

    $('#txtFilterSalesQuotationToDate').datepicker('setDate', (todayDate.getDate() <= 9 ? "0" + todayDate.getDate() : todayDate.getDate()) + "/" + (todayDate.getMonth()+1 <= 9 ? "0" + (todayDate.getMonth()+1) : (todayDate.getMonth()+1) ) + "/" + todayDate.getFullYear());

    //export invoice
    $("#txtExportInvoiceFromDateFilter").datepicker(dteopt) ;
    $("#txtExportInvoiceToDateFilter").datepicker(dteopt) ;
    
    // // last xx days
    $('#txtExportInvoiceFromDateFilter').datepicker('setDate', (startDate.getDate() <= 9 ? "0" + startDate.getDate() : startDate.getDate()) + "/" + (startDate.getMonth()+1 <= 9 ? "0" + (startDate.getMonth()+1) : (startDate.getMonth()+1) ) + "/" + startDate.getFullYear());

    $('#txtExportInvoiceToDateFilter').datepicker('setDate', (todayDate.getDate() <= 9 ? "0" + todayDate.getDate() : todayDate.getDate()) + "/" + (todayDate.getMonth()+1 <= 9 ? "0" + (todayDate.getMonth()+1) : (todayDate.getMonth()+1) ) + "/" + todayDate.getFullYear());
        
    $('#chkAppendixTempOption').bootstrapSwitch();
    $('#chkProjectPlanTempOption').bootstrapSwitch();
    $('#chkMaintenanceTempOption').bootstrapSwitch();
    $('#chkCoverTempOption').bootstrapSwitch();

    //appendix
    if($('#chkAppendixTempOption').is(':checked')){
        $('#divAppendixTemplateList').hide();
        $('#divAppendixTemplateName').show();

        $('#txtChkAppendixTempOption').val("1");
    }else{
        $('#divAppendixTemplateList').show();
        $('#divAppendixTemplateName').hide();

        $('#txtChkAppendixTempOption').val("0");
    }

    //project plan
    if($('#chkProjectPlanTempOption').is(':checked')){
        $('#divProjectPlanTemplateList').hide();
        $('#divProjectPlanTemplateName').show();

        $('#txtChkProjectPlanTempOption').val("1");
    }else{
        $('#divProjectPlanTemplateList').show();
        $('#divProjectPlanTemplateName').hide();

        $('#txtChkProjectPlanTempOption').val("0");
    }

    //maintenance
    if($('#chkMaintenanceTempOption').is(':checked')){
        $('#divMaintenanceTemplateList').hide();
        $('#divMaintenanceTemplateName').show();

        $('#txtChkMaintenanceTempOption').val("1");
    }else{
        $('#divMaintenanceTemplateList').show();
        $('#divMaintenanceTemplateName').hide();

        $('#txtChkMaintenanceTempOption').val("0");
    }

    //cover
    if($('#chkCoverTempOption').is(':checked')){
        $('#divCoverTemplateList').hide();
        $('#divCoverTemplateName').show();

        $('#txtChkCoverTempOption').val("1");
    }else{
        $('#divCoverTemplateList').show();
        $('#divCoverTemplateName').hide();

        $('#txtChkCoverTempOption').val("0");
    }

    if($('#cobsalesitemdisctype').val()=='P'){
        $('#txtsalesitemdiscpercentage').prop("disabled", false);
        $('#txtsalesitemdisctotal').prop("disabled", true);
    } else if($('#cobsalesitemdisctype').val()=='A'){
        $('#txtsalesitemdiscpercentage').prop("disabled", true);
        $('#txtsalesitemdisctotal').prop("disabled", false);
    } else {
        $('#txtsalesitemdiscpercentage').prop("disabled", true);
        $('#txtsalesitemdisctotal').prop("disabled", true);
    }

    if($('#cobSalesMaintenanceDiscType').val()=='P'){
        $('#txtSalesMaintenanceDiscPercentage').prop("disabled", false);
        $('#txtSalesMaintenanceDiscTotal').prop("disabled", true);
    } else if($('#cobSalesMaintenanceDiscType').val()=='A'){
        $('#txtSalesMaintenanceDiscPercentage').prop("disabled", true);
        $('#txtSalesMaintenanceDiscTotal').prop("disabled", false);
    } else {
        $('#txtSalesMaintenanceDiscPercentage').prop("disabled", true);
        $('#txtSalesMaintenanceDiscTotal').prop("disabled", true);
    }
  });
</script>