Php Zend推进无数据提交结束
该程序使用Zend框架和Propel。 我的“_form_genehmigt.phtml”指的是我的索引页面,当我按下save按钮时,执行Antragpeer.php中的updateAction,但数据没有提交。我的MySql数据库中没有新条目。但是firebug中也没有错误消息 //UrlaubController.phpPhp Zend推进无数据提交结束,php,mysql,database,extjs,zend-framework,Php,Mysql,Database,Extjs,Zend Framework,该程序使用Zend框架和Propel。 我的“_form_genehmigt.phtml”指的是我的索引页面,当我按下save按钮时,执行Antragpeer.php中的updateAction,但数据没有提交。我的MySql数据库中没有新条目。但是firebug中也没有错误消息 //UrlaubController.php public function updateAction() { $antrag = AntragPeer::update($_POST);
public function updateAction() {
$antrag = AntragPeer::update($_POST);
if (!count($antrag->getValidationFailures())) {
//$antrag->save(); //nötig??
$this->view->success = true;
$this->view->Urlaubsantrag = $antrag->getId();
} else {
$this->view->success = false;
$this->view->errors = $antrag->getValidationFailures();
}
}
//Antragpeer.php
public static function update($post) {
$con = Propel::getConnection();
$con->beginTransaction();
try {
if (!empty($post['id'])) {
$antrag = self::getById($post['id']);
} else {
$antrag = null;
}
if (is_null($antrag)) {
$antrag = new Antrag();
}
$antrag->fromArray($post, BasePeer::TYPE_FIELDNAME);
if ($antrag->validate()) {
$antrag->save($con);
// Speichere Id wenn neuer Eintrag
if (empty($post['id'])) {
$id = date('y').date('m').date('d').'-A'.$antrag->getId();
$antrag->setId($id);
$antrag->save();
}
} else {
throw new Exception();
}
$con->commit();
} catch (Exception $e) {
$con->rollBack();
if ($e->getMessage() != "") Zend_Registry::get('log')->log($e->getMessage(), Zend_Log::ERR);
}
return $antrag;
}
//_表格_genehmigt.phtml
<script type="text/javascript">
<?php
echo $this->extArrayStore('benutzer', array('id'=>'integer', 'label'=>'string'), AclBenutzerPeer::getBenutzerIdformBenutzerStore());
?>
Ext.onReady(function() {
Ext.tip.QuickTipManager.init(true, {showDelay: 0, dismissDelay: 0});
Ext.define('Gesamt', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'integer'},
{name: 'bezeichnung', type: 'string'},
{name: 'Resturlaub_vorjahr', type: 'string'}
],
idProperty: 'id'
});
Ext.create('Ext.data.Store', {
model: 'Gesamt',
storeId: 'gesamtstore',
proxy: {
type: 'ajax',
url: '<?php echo $this->baseUrl() ?>/Verwaltung/getprogrammbereicheforprojekt?format=json',
extraParams: {
Resturlaub_vorjahr: <?php echo ((($this->data instanceof Gesamt) && $this->data->getResturlaubVorjahr() != "")
? $this->data->getResturlaubVorjahr()
: (($this->mode == "new" && !empty($this->data['Resturlaub_vorjahr']))
? $this->data['Resturlaub_vorjahr']
: "''")); ?>,
Anspruch: <?php echo ((($this->data instanceof Gesamt) && $this->data->getAnspruch() != "")
? $this->data->getAnspruch()
: (($this->mode == "new" && !empty($this->data['Anspruch']))
? $this->data['Anspruch']
: "''")); ?>,
Gesamt: <?php echo ((($this->data instanceof Gesamt) && $this->data->getGesamt() != "")
? $this->data->getGesamt()
: (($this->mode == "new" && !empty($this->data['Gesamt']))
? $this->data['Gesamt']
: "''")); ?>,
csrf_token: '<?php echo HelperFunctions::getCSRFToken(); ?>'
},
reader: {
type: 'json',
root: 'Gesamt',
totalProperty: 'totalcountgesamt'
}
},
listeners: {
load: {
fn:function(records, operation, success) {
var modelDest = Ext.getCmp('Resturlaub_vorjahr');
if (this.getById(modelDest.getValue()) === null) {
modelDest.setValue('');
}
if (modelDest.store.data.length > 0) {
modelDest.setDisabled(false);
} else {
modelDest.setDisabled(true);
}
}
}
}
});
Ext.define('Urlaubsantrag', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'integer'},
{name: 'typ', type: 'string'},
{name: 'typ_icon', type: 'string'},
{name: 'datum', type: 'string'},
{name: 'datum_grid', type: 'string'},
{name: 'mitarbeiter_name', type: 'string'},
{name: 'kommentar_grid', type: 'string'},
{name: 'status', type: 'string'},
{name: 'mitarbeiter_id', type: 'string'},
{name: 'Von_Datum', type: 'string'},
{name: 'Bis_Datum', type: 'string'},
{name: 'Anzahl_Tage', type: 'string'},
{name: 'Antrags_Datum', type: 'string'},
{name: 'Resturlaub_Tage', type: 'string'},
{name: 'Gesamt_Anzahl_Tage', type: 'string'},
{name: 'Kommentar', type: 'string'},
{name: 'Genehmigt_Von', type: 'string'},
{name: 'Jahr', type: 'string'},
{name: 'Genehmigt', type: 'boolean'},
{name: 'mitarbeiter_gesamt', type: 'string'},
{name: 'Resturlaub_vorjahr', type: 'string'},
{name: 'Anspruch', type: 'string'},
{name: 'Sonderurlaub', type: 'string'},
{name: 'Gesamt', type: 'string'},
{name: 'Jahr', type: 'string'}
],
idProperty: 'id'
});
Ext.create('Ext.data.Store', {
model: 'Urlaubsantrag',
storeId: 'Urlaubsantragstore',
sorters: {
property: 'created_at_grid',
direction: 'DESC'
},
sortOnLoad: true,
proxy: {
type: 'ajax',
//url?
url: '<?php echo $this->baseUrl(); ?>/urlaub/update?format=json',
extraParams: {
antragId: <?php echo (($this->data instanceOf Antrag)
? $this->data->getId()
: "''"); ?>
},
reader: {
type: 'json',
root: 'array',
totalProperty: 'totalcount'
}
},
listeners: {
'load': function (records, options, success) {
if (Ext.data.StoreManager.lookup('Urlaubsantragstore').getTotalCount() > 0) {
Ext.data.StoreManager.lookup('Urlaubsantragstore').each(function (record) {
if (record.get('Genehmigt') === false) {
Ext.getCmp('formularmeldungen_erledigt').show();
return false;
}
});
} else {
Ext.getCmp('formularmeldungen_erledigt').hide();
}
}
},
autoLoad: <?php echo (($this->data instanceOf Antrag) ? 'true' : 'false'); ?>,
remoteFilter: true
});
var formPanelAntrag = Ext.create('Ext.form.Panel', {
renderTo: 'form-ctantrag',
defaultType: 'textfield',
id: 'formPanelAntrag',
trackResetOnLoad: true,
width: <?php echo Constants::EXT4_PANEL_WIDTH ?>,
items: [
{
xtype: 'panel',
border: false,
bodyPadding: 10,
items: [
{
xtype: 'fieldset',
title: 'Urlaubsantrag',
defaults: {
labelWidth: 200,
anchor: '100%'
},
items: [
{
xtype: 'fieldset',
title: 'Allgemeine Angaben',
defaults: {
labelWidth: 200,
anchor: '100%'
},
items: [
{
xtype: 'hiddenfield',
name: 'id'
},
{
xtype: 'datefield',
id: 'Antrags_Datum',
name: 'Antrags_Datum',
fieldLabel: 'Antrags Datum',
format: 'd.m.Y',
value: '<?php echo date("d.m.Y") ?>',
tabIndex: 1
},
{
xtype: 'timefield',
id: 'datum_zeit',
name: 'datum_zeit',
fieldLabel: 'Zeit',
format: 'H:i',
value: '<?php echo date("H:i"); ?>',
tabIndex: 2
},
{
xtype: 'combo',
fieldLabel: 'Mitarbeiter',
name: 'mitarbeiter_id',
id: 'mitarbeiter_id',
store: 'benutzer_store',
queryMode: 'local',
displayField: 'label',
valueField: 'id',
value: <?php echo (($this->mode == "new") ? Zend_Auth::getInstance()->getIdentity()->getId() : "''"); ?>,
forceSelection: true,
tabIndex: 3
},
{
xtype: 'displayfield',
fieldLabel: 'Resturlaub Vorjahr',
name: 'Resturlaub_vorjahr',
id: 'Resturlaub_vorjahr',
store: 'gesamtstore',
queryMode: 'local',
displayField: 'label',
valueField: 'Resturlaub_vorjahr', //value + 'Tage'
value: <?php echo (($this->mode == "new") ? json_encode($this->data['Resturlaub_vorjahr']) : "''"); ?>,
disabled: true
},
{
xtype: 'displayfield',
name: 'Anspruch Aktuell',
id: 'Anspruch',
fieldLabel: 'Anspruch dieses Jahr',
disabled: true
},
{
xtype: 'displayfield',
name: 'Gesamt',
id: 'Gesamt',
fieldLabel: 'Gesamt',
disabled: true
},
{
xtype: 'displayfield',
name: 'Vorhanden aktuell',
id: 'Vorhanden_dieses_jahr',
fieldLabel: 'Vorhanden dieses Jahr',
disabled: true
}
]
},{
xtype: 'fieldset',
title: 'Urlaubs Angaben',
defaults: {
labelWidth: 200,
anchor: '100%'
},
items: [
{
xtype: 'datefield',
name: 'Von Datum',
id: 'VonDatum',
fieldLabel: 'Von',
tabIndex: 4
},
{
xtype: 'datefield',
name: 'Bis Datum',
id: 'BisDatum',
fieldLabel: 'Bis',
tabIndex: 5
},
{
xtype: 'numberfield',
name: 'Anzahl Tage',
id: 'AnzahlTage',
fieldLabel: 'Anzahl Tage (Abzgl. Wochenenden)',
tabIndex: 6
},
{
xtype: 'checkbox',
name: 'Sonderurlaub',
inputValue: '1',
fieldLabel: 'Sonderurlaub',
anchor: '100%',
tabIndex: 7
},
{
xtype: 'displayfield',
name: 'Resturlaub tage',
id: 'Resturlaub',
fieldLabel: 'Resturlaub',
disabled: true
}
]
},
{
xtype: 'fieldset',
title: 'Kommentar',
cls: 'fieldset_innerdiv',
defaults: {
labelWidth: 200,
anchor: '100%'
},
items: [
{
xtype: 'textarea',
name: 'Kommentar',
id: 'Kommentar',
tabIndex: 8
}
]
},
{
xtype: 'fieldset',
title: 'Genehmigt',
cls: 'fieldset_innerdiv',
defaults: {
labelWidth: 200,
anchor: '100%'
},
items: [
{
xtype: 'checkbox',
name: 'Genehmigt Ja',
id: 'Genehmigt_ja',
inputValue: '1',
fieldLabel: 'Ja',
anchor: '100%',
tabIndex: 9
},
{
xtype: 'checkbox',
name: 'Genehmigt Nein',
id: 'Genehmigt_nein',
inputValue: '2',
fieldLabel: 'Nein',
anchor: '100%',
tabIndex: 10
},
{
xtype: 'combo',
fieldLabel: 'Genehmigt Von',
name: 'mitarbeiter_id',
id: 'genehmigt_von',
store: 'benutzer_store',
queryMode: 'local',
displayField: 'label',
valueField: 'id',
value: <?php echo (($this->mode == "new") ? Zend_Auth::getInstance()->getIdentity()->getId() : "''"); ?>,
forceSelection: true,
tabIndex: 11
}
]
}
]
}
]
}
],
buttons: [
{
text: '{LB_CANCEL_AND_BACK}',
icon: '<?php echo $this->baseUrl() ?>/images/<?php echo Constants::ICON_LOESCHEN; ?>',
handler: function () {
window.location.href = "<?php echo $this->baseUrl() ?>/urlaub/index?csrf_token=<?php echo HelperFunctions::getCSRFToken() ?>";
},
tabIndex: 26
},
{
text: '{LB_SAVE_NEW}',
id: 'btn_save',
icon: '<?php echo $this->baseUrl() ?>/images/<?php echo Constants::ICON_SPEICHERN; ?>',
formBind: true,
handler: function(){
if (formPanelAntrag.isDisabled() == false) {
this.up('form').getForm().submit({
url: '<?php echo $this->baseUrl() ?>/urlaub/update?format=json',
submitEmptyText: false,
success: function (form, action) {
window.location.href = '<?php echo $this->baseUrl() ?>/urlaub/index?csrf_token=<?php echo HelperFunctions::getCSRFToken(); ?>';
},
failure: function (form, action) {
goToTop();
flash('error', {
title: '<?php echo Text::LB_FORMPANEL_FLASH_ERROR_TITLE ?>',
msg: '<?php echo Text::LB_FORMPANEL_FLASH_ERROR_MSG ?>',
fadeOut: 1,
delay: 7000
});
}
});
}
},
tabIndex: 27
}]
});
});
</script>
<div id="form-ctantrag"></div>
Ext.onReady(函数(){
init(true,{showDelay:0,dismissDelay:0});
Ext.define('Gesamt'{
扩展:“Ext.data.Model”,
字段:[
{name:'id',type:'integer'},
{name:'bezeichung',键入:'string'},
{name:'Resturlaub_vorjahr',键入:'string'}
],
idProperty:“id”
});
Ext.create('Ext.data.Store'{
型号:“Gesamt”,
storeId:“gesamtstore”,
代理:{
键入:“ajax”,
url:“/Verwaltung/getprogrammbereicheforprojekt?format=json”,
外部参数:{
Resturlaub_vorjahr: