<?php
include_once("_dirinfo.php");
include_once(PATH_TO_ROOT."init.php");


$dbConfigCapi = configLoader::loadConfig('capi');
	
$sql = "SELECT  translate_key, translate_text 
				FROM  ".DB_WARPIT_MAIN."._languagePack 
					WHERE id_programme = 2 AND id_language = ".$dbConfigCapi['default-language']." AND sub_page = 'capi'";
	//echo $sql;
	$res = $db->SQLexecute($sql);
	while ($zad = $db->fetchAssoc($res)) $languagePack[$zad['translate_key']] = $zad['translate_text'];
	

?>
 var FormAppointment = new Ext.FormPanel({
        labelWidth: 100, // label settings here cascade unless overridden
        url:'_ajax/ajax.save-appointments.php',
        
        frame:true,
        
        bodyStyle:'padding:5px 5px 5px 5px',
        
        defaultType: 'textfield',

        items: [
        	{
                fieldLabel: '<?php echo $languagePack['contact-person'];?>',
                width: 350,
                name: 'priimek_gosp',
                allowBlank : true
                
            },
        	{
        		xtype : 'textarea',
                fieldLabel: '<?php echo $languagePack['comment'];?>',
                
                width: 350,
                name: 'komentar'
                
            },{
        		xtype : 'datefield',
                fieldLabel: '<?php echo $languagePack['date-time'];?>',
                name: 'input_date',
                format: 'Y-m-d',
                value: '<?php echo date('Y-m-d'); ?>',
                allowBlank : false,
                blankText : 'Requiered field',
                width: 100
                
            }    ,{
        		xtype : 'timefield',
                fieldLabel: 'Time',
                name: 'input_time',
                format:"H:i",
                <?php 
                
                $t = (round(date("i")/15)*15);
                if ($t < 10) $t = "0".$t;
                
                ?>
                value: '<?php echo date("H:").$t;?>',
                allowBlank : false,
                blankText : 'Requiered field',
                  width: 100
                
            }                  
        ],

        buttons: [{
            text: '<?php echo $languagePack['save'];?>',
            handler: function() {
            	
            	FormAppointment.getForm().submit({
            		params: { action: 'save', id_visit : '<?php echo $_POST['id_visit'];?>' },
            		success: function(resp,opt) {  
            	  		
            				Ext.getCmp('CapiAppointmentsGrid').getStore().reload();	
            	        	tb.show();  
							Ext.getCmp('MainPanel').doLayout();
								
            	        	Ext.getCmp('surv-panel-<?php echo $_SESSION['capi']['id_project'];?>').destroy();
            	        	showTools();
            	        	hideSampleFunctions();
            				Ext.getCmp('WindowAppointment').close();
            	        	
            	        	
            		}
            	})
            }
        }]
    });
 	 



WindowAppointment = new Ext.Window({
   
	id:'WindowAppointment',
	layout:'fit',
	title: '<?php echo $languagePack['make-appointment'];?>',
	width:500,
	height:240,
	closeAction:'close',
    plain: true,
    modal: true,
    items:FormAppointment
}).show()    