{
    xtype: 'fieldset', 
    id: 'confirm_credit_payment_order',
    anchor: '-0',
    layout: 'form',
    title: '<?php echo $LangPack->GetLabel("delivery_finish_window", "credit_payment_fieldset_title","Pregled naročila");?>',
    items:[
    {
        xtype: 'label',
        id: 'confirm_text',
        listeners:{
            'afterrender': function(label){
               	 	var itemCode = '<?php echo $LangPack->GetLabel("delivery_finish_window", "item_code_confirm_text","ŠIFRA IZDELKA");?>';
               	 	var code = '<?php echo $LangPack->GetLabel("delivery_finish_window", "code_confirm_text","ima šifro");?>';
                
	                var text = itemCode + ' ( <?php echo $zad['product_name']; ?> '+code+': <?php echo $zad['product_code']; ?> ) / ';
	                text += '<?php echo $zad['product_name']; ?> / ';
	                text += '<?php echo $zad['product_amount']; ?> / ';
	                text += '<?php echo round($zad['product_price'],2)." EUR";?> <br>';
	                
	                text += '<b><?php echo $LangPack->GetLabel("delivery_finish_window", "numberOfAnnuities", "Število anuitet"); ?>: <?php echo $zad['number_of_payments']; ?></b><br>';
	                
	                <?php
	                	$sql = "SELECT * 
	                	          FROM ".WARPIT_CRM."._loanCreditsDefinitions as d 
	                	          LEFT JOIN ".WARPIT_CRM."._loanCreditsIntervals as i 
	                	          ON i.id = d.id_interval WHERE i.id_product = '".$zad['article_id']."' 
	                	          AND d.numberOfAnnuities = '".$zad['number_of_payments']."' 
	                	          AND d.id_interval = '".$zad['loanIntervalId']."'";
						$res = $db->SQLexecute($sql);
						$loan = $db->fetchAssoc($res);
	                ?>
	                text += '<?php echo $LangPack->GetLabel("delivery_finish_window", "CreditPrice", "Znesek kredita znaša"); ?>: <?php echo round($loan['CreditPrice'] * $zad['product_amount'],2); ?> <?php echo MONEY_VALUE;?><br>';
	                text += '<?php echo $LangPack->GetLabel("delivery_finish_window", "AnnuitiePrice", "Znesek anuitete znaša"); ?>: <?php echo round($loan['AnnuitiePrice'] * $zad['product_amount'],2); ?> <?php echo MONEY_VALUE;?><br>';
	                text += '<?php echo $LangPack->GetLabel("delivery_finish_window", "DepositePrice", "Polog znaša"); ?>: <?php echo round($loan['DepositePrice'] * $zad['product_amount'],2); ?> <?php echo MONEY_VALUE;?><br>';
	                text += '<?php echo $LangPack->GetLabel("delivery_finish_window", "ToatlAmount", "Skupni znesek znaša"); ?>: <?php echo round(($loan['CreditPrice'] + $loan['DepositePrice']) * $zad['product_amount'],2); ?> <?php echo MONEY_VALUE;?>';
                    label.update(text);                  
                }
            }
        }]
   },{
   		xtype: 'fieldset', 
	    id: 'credit_payment',
	    anchor: '-0',
	    layout: 'form',
	    title: '<?php echo $LangPack->GetLabel("delivery_finish_window", "loan_credit_payment","Loan Kredit");?>',
	    items:[new Ext.form.ComboBox({
        	fieldLabel: '<?php echo $LangPack->GetLabel("delivery_finish_window", "payment_type_combo","Način plačila");?>',
		    typeAhead: true,
		    editable: false,
		    width: 250,
		    name: 'delivery_finish_credit_card_type',
		    hiddenName: 'data[delivery_finish_credit_card_type]',
		    id: 'delivery_finish_credit_card_type',
		    triggerAction: 'all',
		    lazyRender: true,
		    mode: 'local',
            store: new Ext.data.ArrayStore({
		        fields: [ 'id', 'value' ],
		        data: [
		        	[ 1, '<?php echo $LangPack->GetLabel("delivery_finish_window", "credit_card_payment_type","Plačilo s plačilno kartico");?>' ],
		        	[ 2, '<?php echo $LangPack->GetLabel("delivery_finish_window", "money_payment_type","Plačano z denarjem");?>' ]
		        ]
		    }),
		    value: 1,
		    valueField: 'id',
		    displayField: 'value'
		}),
		{
			xtype: 'compositefield',
			items:[
				new Ext.form.ComboBox({
			        fieldLabel: '<?php echo $LangPack->GetLabel("delivery_finish_window", "payments_number_type_title","ŠTEVILO OBROKOV");?>', 
			        mode: 'local',
			        triggerAction: 'all',
			        editable: false,
			        width: 80,
			        name: 'data[delivery_finish_loan_payment]',
			        renderer : function(a, metaData, record) {
			            var st = Ext.getCmp('credit_lon_stevilo_obrokov').getStore();
			            if(st.find('id',a) != -1){
			                var r = st.getAt(st.find('id',a));
			                return r.data.value;
			            }
			        },
			        id: 'delivery_finish_loan_payment',
			        lazyRender: true,
			        store: new Ext.data.ArrayStore({
			            fields:['id', 'value'],
			            data:[
			                ['1', '2'],
			                ['2', '5'],
			                ['3', '8'],
			                ['4', '11'],
			                ['5', '13'],
			                ['6', '17'],
			                ['7', '21'],
			                ['8', '23'],
			                ['9', '31'],
			                ['10', '35']
			            ]
			        }),
			        listeners:{
			        	select:function(comp, a, b){
			        		Ext.Ajax.request({
			        			url: '<?php echo $ajax;?>',
			        			params:{
			        				action: 'getDeposit',
			        				id_product: '<?php echo $zad['article_id'];?>',
			        				id: '<?php echo $id;?>',
			        				numberOfAnnuities: a.data.value
			        			},
			        			success: function(resp, opt){
			        				var data = Ext.decode(resp.responseText);
			        				if(data.success)
				        				Ext.getCmp('pologLabel').update("<?php echo $LangPack->GetLabel("delivery_finish_window", "loan_paid_title","Polog");?>: " + data.polog+"<?php echo MONEY_VALUE;?>");	
			        			}
			        		});
			        	}
			        },
			        valueField: 'id',
			        displayField: 'value'
			  }),
			  {
			  	xtype: 'label',
			  	id: 'pologLabel'
			  }
			]
		},
		new Ext.form.ComboBox({
            fieldLabel: '<?php echo $LangPack->GetLabel("delivery_finish_window", "amount_paid_label","ZNESEK PLAČAN");?>', 
            mode: 'local',
            triggerAction: 'all',
            editable: false,
            width: 100,
            hiddenName: 'data[delivery_amount_paid]',
            name: 'data[delivery_amount_paid]',
            renderer : function(a, metaData, record) {
                var st = Ext.getCmp('prikazi_polog').getStore();
                if(st.find('id',a) != -1){
                    var r = st.getAt(st.find('id',a));
                    return r.data.value;
                }
            },
            id: 'delivery_amount_paid',
            lazyRender: true,
            store: new Ext.data.ArrayStore({
                fields:['id', 'value'],
                data:[
                    ['1', '<?php echo $LangPack->GetLabel("CRM_all", "YES","DA");?>'],
                    ['2', '<?php echo $LangPack->GetLabel("CRM_all", "NO","NE");?>']
                    
                ]
            }),
            valueField: 'id',
            displayField: 'value'
       })
		,{
			xtype: 'datefield',
			format: 'd.m.Y',
        	name: 'data[delivery_finish_date]',
        	id: 'delivery_date',
        	fieldLabel: '<?php echo $LangPack->GetLabel("delivery_finish_window", "delivery_date_picker","Datum dostave"); ?>',
        	allowBlank: false,
        	value: '<?php echo $zad['datum_dostave']; ?>'
		},{
			xtype: 'textarea',
        	name: 'data[delivery_finish_comment]',
        	id: 'note',
        	fieldLabel: '<?php echo $LangPack->GetLabel("delivery_finish_window", "note_textarea","Opomba"); ?>',
        	anchor: '100%',
        	value: '<?php echo $zad['delivery_finish_comment'] ?>'
		}
	    ]
    }
