<?php

if (!defined('sugarEntry') || !sugarEntry)
    die('Not A Valid Entry Point');

/* * *******************************************************************************
 * SugarCRM is a customer relationship management program developed by
 * SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301 USA.
 *
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
 *
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU General Public License version 3.
 *
 * In accordance with Section 7(b) of the GNU General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 *
 * "Powered by SugarCRM".
 * ****************************************************************************** */

$viewdefs['EcmReceipts']['DetailView'] = array(
    'templateMeta' => array(
        'form' => array(
            'buttons' => array(
                array(
                    'customCode' =>
                    '
                    {if $bean->aclAccess("edit") && $bean->status=="registered"}
                        <input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="button" onclick="this.form.return_module.value=\'EcmReceipts\'; this.form.return_action.value=\'DetailView\'; this.form.return_id.value=\'{$id}\'; this.form.action.value=\'EditView\';" type="submit" name="Edit" id="edit_button" value="{$APP.LBL_EDIT_BUTTON_LABEL}">
                    {/if}
                    ',
				),
				array(
					'customCode' => '
					 <input title="Ufiskalnij" class="button" onclick="register_print();" type="button" name="register" id="register" value="Ufiskalnij paragon"><br><div id="print_link"></div>
					',
				),
                
//                array(
//                    'customCode' =>
//                    '
//                    {if $bean->aclAccess("edit") && $bean->status=="registered"}
//                        <input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="button" onclick="this.form.return_module.value=\'EcmQuestionnaires\'; this.form.return_action.value=\'DetailView\'; this.form.isDuplicate.value=true; this.form.action.value=\'EditView\'; this.form.return_id.value=\'{$id}\';" type="submit" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}" id="duplicate_button">
//                    {/if}
//                    ',
//                ),
//                array(
//                    'customCode' =>
//                    '
//                    {if $bean->aclAccess("delete") && $bean->status=="registered"}
//                        <input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="button" onclick="this.form.return_module.value=\'EcmQuestionnaires\'; this.form.return_action.value=\'ListView\'; this.form.action.value=\'Delete\'; return confirm(\'{$APP.NTC_DELETE_CONFIRMATION}\');" type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}">
//                    {/if}
//                    ',
//                ),
				array(
					'customCode' => '{$CATALOGUE}'
				),
//                array(
//                    'customCode' =>
//                    '
//                    {if $bean->type=="correct" && !$hasCorrect}
//                        <input name="create_ks" id="create_ks" title="Create KS Document" class="button" onclick="window.location = \'index.php?module=EcmStockDocCorrects&out_module=EcmReceipts&action=EditView&out_id={$fields.id.value}\';" type="button" value="Create KS Document">
//                    {/if}
//                    ',
//                ),
//                array(
//                    'customCode' =>
//                    '
//                    {if $bean->aclAccess("edit") && $fields.accepted.value == 1 && $OPT.user.confirm_receipts == 1}
//                        <input title="{$MOD.LBL_REPAIR_BUTTON_TITLE}" accessKey="{$MOD.LBL_REPAIR_BUTTON_KEY}" class="button" onclick="window.location = \'index.php?module=EcmReceipts&action=DetailView&record={$fields.id.value}&status=not_accepted&return_module=\'+this.form.return_module.value+\'&return_action=\'+this.form.return_action.value+\'&return_id=\'+this.form.return_id.value;" type="button" name="Repair" id="repair_button" value="{$MOD.LBL_REPAIR_BUTTON_LABEL}">
//                    {/if}
//                    ',
//                ),
//                array(
//                    'customCode' =>
//                    '
//                    <input title="" accessKey="" class="button" onclick="window.location = \'index.php?module=EcmReceipts&action=downloadXML&record={$fields.id.value}\'" type="button" name="Repair" id="repair_button" value="Create XML">
//                    ',
//                ),
//                array(
//                    'customCode' =>
//                    '
//                    <input title="" accessKey="" class="button" onclick="window.location = \'index.php?module=EcmReceipts&action=downloadXML&record={$fields.id.value}&duplicate=1\'" type="button" name="c_dup_xml" id="c_dup_xml" value="Create Duplicate XML">
//                    ',
//                ),
//                array(
//                    'customCode' =>
//                    '
//                    <input name="workreport_to_invoice" id="workreport_to_invoice" title="{$MOD.LBL_WORKREPORT_TO_INVOICE_BUTTON_TITLE}" accessKey="{$MOD.LBL_WORKREPORT_TO_INVOICE_BUTTON_KEY}" class="button" onclick="window.location = \'index.php?module=EcmReceipts&action=EditView&work_report_record={$fields.id.value}\';" type="button" value="{$MOD.LBL_WORKREPORT_TO_INVOICE}">
//                    ',
//                ),
            ),
            'hidden' => array(
                '
                <input type="hidden" name="position_list" id="position_list" value=\'{$POSITION_LIST}\'>
                ',
//                '
//                <input type="hidden" name="discount" id="discount" value=\'{$fields.discount.value}\'>
//                ',
//                '
//                <input type="hidden" name="parent_type" id="parent_type" value="{$fields.parent_type.value}">
//                ',
                '
                <input type="hidden" name="parent_id" id="parent_id" value="{$fields.parent_id.value}">
                ',
                '
                <input type="hidden" name="assigned_user_id" id="assigned_user_id" value="{$fields.assigned_user_id.value}">
                ',
                '
                <input type="hidden" name="email_id" id="email_id" value="">
                ',
                '
                <span id="quickInfoH2" style="display:none;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>{$fields.document_no.value}</span> - <span>{$fields.parent_name.value}</span> - <span>{$fields.parent_contact_name.value}</span> - <span>{$fields.parent_address_street.value}</span>&nbsp; &nbsp;<span>{$fields.parent_address_postalcode.value}</span>&nbsp;<span>{$fields.parent_address_city.value}</span>&nbsp; &nbsp;<span>{$fields.parent_address_country.value}</span> - <span id="total_h">{$fields.total.value}</span></span>
                ',
            ),
        ),
        'maxColumns' => '2',
        'widths' => array(
            array(
                'label' => '10',
                'field' => '30',
            ),
            array(
                'label' => '10',
                'field' => '30',
            )
        ),
        'includes' => array(
            array(
                'file' => 'include/JSON.js',
            ),
            array(
                'file' => 'modules/EcmReceipts/MyTable.js',
            ),
            array(
                'file' => 'include/ECM/EcmPreviewPDF/EcmPreviewPDF.js',
            ),
            array(
                'file' => 'modules/EcmReceipts/EcmReceiptsDetailView.js',
            ),
        ),
    ),
    'panels' => array(
        'LBL_DETAILS_TAB' => array(
            array(
                'document_no',
                'assigned_user_name',
            ),
            array(
                'parent_name',
                'type',
            ),
            array(
                'register_date',
                array(
                    'name' => 'ecmpaymentcondition_name',
                    'customCode' =>
                    '
                    {$fields.ecmpaymentcondition_name.value}
                    ',
                ),
            ),
            array(
                'sell_date',
                '',//'ecmreceipt_name',
            ),
            array(
                'payment_date',
                'template_name',
            ),
            array(
                'name',
                ),
            array(
                array(
                    'name' => 'to_informations',
                    'allCols' => true,
                    'hideLabel' => true,
                    'customCode' =>
                    '
                    <div class="tabForm" style="border-top:none;width:100%;height:1px;padding:0px;align:center;"></div>
                    <h4>{$MOD.LBL_TO_PAYMENTS}</h4>
                    ',
                ),
            ),
            array(
                array(
                    'name' => 'to_paid',
                    'label' => 'LBL_TO_PAID',
                    'customCode' =>
                    '
                    {$TO_PAID}
                    ',
                ),
                'payment_date_d',
            ),
            array(
                'prepaid',
                'payment_date',
            ),
            array(
                'prepaid_nr',
                'payment_method',
            ),
            array(
                'paid_val',
                'payment_method_paid',
            ),
            array(
                array(
                    'name' => 'left',
                    'label' => 'LBL_LEFT',
                    'customCode' =>
                    '
                    {$LEFT}
                    ',
                ),
                array(
                    'name' => 'weight_total',
                    'label' => 'LBL_WEIGHT_NETTO',
                    'customCode' =>
                    '
                    {$WEIGHT_TOTAL}
                    ',
                ),
            ),
            array(
                array(
                    'name' => 'to_informations',
                    'allCols' => true,
                    'hideLabel' => true,
                    'customCode' =>
                    '
                    <div class="tabForm" style="border-top:none;width:100%;height:1px;padding:0px;align:center;"></div>
                    <h4>{$MOD.LBL_TO_INFORMATIONS}</h4>
                    ',
                ),
            ),
            array(
                'parent_name',
                'to_nip',
            ),
            array(
                array(
                    'name' => 'parent_contact_name',
                    'customCode' =>
                    '
                    {$fields.parent_contact_title.value} {$fields.parent_contact_name.value}
                    ',
                ),
                array(
                    'name' => 'currency_id',
                    'label' => 'LBL_CURRENCY',
                    ),
            ),
            array(
                'parent_address_street',
                'currency_value',
            ),
            array(
                array(
                    'name' => 'parent_address_city',
                    'customCode' =>
                    '
                    {$fields.parent_address_postalcode.value} {$fields.parent_address_city.value}
                    ',
                ),
                array(
                    'name' => 'pdf_type',
                    'label' => 'LBL_PDF_TYPE',
                    ),
            ),
            array(
                'parent_address_country',
            ),
            array(
                array(
                    'name' => 'to_informations',
                    'allCols' => true,
                    'hideLabel' => true,
                    'customCode' =>
                    '
                    <div class="tabForm" style="border-top:none;width:100%;height:1px;padding:0px;align:center;"></div>
                    <h4>{$MOD.LBL_PARENT_SHIPPING_ADDRESS}</h4>
                    ',
                ),
            ),
            array(
                'parent_shipping_address_name',
                ),
            array(
                'parent_shipping_address_street',
                ),
            array(
                array(
                    'name' => 'parent_shipping_address_city',
                    'customCode' =>
                    '
                    {$fields.parent_shipping_address_postalcode.value} {$fields.parent_shipping_address_city.value}
                    ',
                ),
            ),
            array(
                'parent_shipping_address_country',
                ),
        ),
        'LBL_ITEMS_TAB' => array(
            array(
                array(
                    'name' => 'items_list_panel',
                    'allCols' => true,
                    'hideLabel' => true,
                    'customCode' =>
                    '
                    <link rel="stylesheet" type="text/css" href="modules/EcmReceipts/MyTable.css" />
                    <div style="width:100%;border: 1px solid rgb(48,192,255);background-color:white;height:{$OPT.position_table_height}px;max-height:{$OPT.position_table_height}px;overflow:auto;">
                        <table class="positions" style="width:100%;" id="itemsTable">
                            <thead id="head">
                                <tr id="tr">
                                    <td width="4%">{$MOD.LBL_EDITTABLE_NO}</td>
                                    <td width="10%">{$MOD.LBL_EDITTABLE_CODE}</td>
                                    <td width="37%">{$MOD.LBL_EDITTABLE_NAME}</td>
                                    <td width="5%">{$MOD.LBL_EDITTABLE_QUANTITY}</td>
                                    <td width="8%">{$MOD.LBL_EDITTABLE_UNIT}</td>
                                    <td width="10%">{$MOD.LBL_EDITTABLE_PRICE_SUB}</td>
                                    <td width="6%">{$MOD.LBL_EDITTABLE_DISCOUNT}</td>
                                    <td width="10%">{$MOD.LBL_EDITTABLE_PRICE}</td>
                                    <td width="6%">{$MOD.LBL_EDITTABLE_VAT}</td>
                                    <td width="10%">{$MOD.LBL_EDITTABLE_TOTAL}</td>
                                </tr>
                            </thead>
                            <tbody id="tbody">
                            </tbody>
                        </table>
                    </div>
                    <table width="100%"" cellpadding="0" cellspacing="0" border="0">
                        <tr>
                        <td width="55%" class="dataLabel" valign="top">
                            &nbsp;
                        </td>                                                                               <!--color:#b3b9cf;-->
                        <td width="40%" class="dataField" style="text-align: left;">
                            <br>
                            <table id="result_table" cellpadding="0" cellspacing="0" style="width:100%; height:100%; border: 1px solid rgb(48,192,255);">
                                <tr id="subtotal_tr">
                                    <td class="positionsLabel" style="border-top:0px;">
                                        {$MOD.LBL_SUBTOTAL}
                                    </td>
                                    <td class="positionsField" style="border-top:0px;">
                                        <input type="text" style="border:0px;font-weight:900;width:100%;text-align:right;" readonly="readonly" name="subtotal" id="subtotal" value=\'{$fields.subtotal.value}\'>
                                    </td>
                                </tr>
                                <tr id="total_tr">
                                    <td class="positionsLabel">
                                        {$MOD.LBL_TOTAL}
                                    </td>
                                    <td class="positionsField">
                                        <input type="text" readonly="readonly" style="border:0px;font-weight:900;width:100%;text-align:right;" name="total" id="total" value=\'{$fields.total.value}\'>
                                    </td>
                                </tr>
                            </table>
                        </td>
                            <td width="5%" class="dataField" style="text-align: left;">
                                &nbsp;
                            </td>
                        </tr>
                    </table>
                    ',
                )
            ),
        ),
        'LBL_TEXTS_TAB' => array(
            array(
                'header_text',
                ),
            array(
                'footer_text',
                ),
            array(
                'ads_text',
                ),
        ),
//        'LBL_PREVIEW_TAB' => array(
//            array(
//                array(
//                    'name' => 'preview_panel',
//                    'allCols' => true,
//                    'hideLabel' => true,
//                    'customCode' =>
//                    '
//                    <span id="previewPDF" width="100%" height="100%"></span>
//                    ',
//                ),
//            ),
//        ),
        'LBL_PREVIEW_TAB' => array(
            array(
                array(
                    'name' => 'preview_panel',
                    'allCols' => true,
                    'hideLabel' => true,
                    'customCode' =>
                    '
                    <select id="preview_type" name="preview_type">
                        <option value="">Paragon</option>
                        <option value="inv">Faktura</option>
                        <option value="exp">Lista rozchodowa</option>
                    </select>
                    <input type="button" class="button" onClick="setPREVIEW();" value="Generuj"/>
                    <hr/>
                    <span id="previewPDF" width="100%" height="100%"></span>
                    ',
                ),
            ),
        ),
//        'LBL_EMAIL_TAB' => array(
//            array(
//                array(
//                    'name' => 'email_panel',
//                    'allCols' => true,
//                    'hideLabel' => true,
//                    'customCode' =>
//                    '
//                    {$EMAIL_LINK_TAB}
//                    <span id="emailTAB" width="100%" height="100%"></span>
//                    ',
//                ),
//            ),
//        ),
    ),
);