• 0

كيف أحذف شاشة confirm في سكربت Mysqli CRUD؟

السلام عليكم

استخدم سكربت Mysqli CRUD - Data Management System 

طريقة عمل السكربت عند اضافة سجل جديد من خلال form لا يتم اضافته مباشرة الى قاعدة البيانات بل يوجد شاشة confirm.

أريد حذف شاشة confirm لكن validation  على form مربوط بشاشة confirm h.

كيف أحذف شاشة confirm مع الاحتفاظ بvalidation  على form؟

رابط السكربت اونلاين

الكود المسؤول عن ذلك:

switch ($this->action) {
			case 'copy_confirm' :
			case 'form_confirm' :
				$saveOnclick = "$('#action_type').val('save'); $('#".$this->uid."').submit();";
				$fa->addChildren ( new HtmlTag ( 'a', array (
						'class' => 'btn btn-success',
						'onclick' => $saveOnclick
				), btn_save ) );
				$backOnclick = "$('#action_type').val('back'); $('#".$this->uid."').submit();";
				$fa->addChildren ( new HtmlTag ( 'a', array (
						'class' => 'btn ',
						'onclick' => $backOnclick
				), btn_back ) );
				$fieldset->addChildren ( $controlGroup );
				break;
			case 'view' :
				$queryString [$this->actionKey] = 'index';
				if (isset ( $queryString ['key'] )) {
					unset ( $queryString ['key'] );
				}
				$fa->addChildren ( new HtmlTag ( 'a', array (
						'class' => 'btn ',
						'href' => '?' . http_build_query ( $queryString, '', '&' )
				), btn_cancel ) );
				$fieldset->addChildren ( $controlGroup );
				break;
			case 'delete' :
				$deleteOnclick = "$('#action_type').val('delete'); $('#".$this->uid."').submit();";
				$fa->addChildren ( new HtmlTag ( 'a', array (
						'class' => 'btn btn-danger',
						'onclick' => $deleteOnclick
				), btn_delete ) );
				$queryString [$this->actionKey] = 'index';
				if (isset ( $queryString ['key'] )) {
					unset ( $queryString ['key'] );
				}
				$fa->addChildren ( new HtmlTag ( 'a', array (
						'class' => 'btn ',
						'href' => '?' . http_build_query ( $queryString, '', '&' )
				), btn_cancel ) );
				$fieldset->addChildren ( $controlGroup );
				break;
			case 'form' :
			default :
				$confirmOnclick = "$('#action_type').val('confirm'); $('#".$this->uid."').submit();";
				$fa->addChildren ( new HtmlTag ( 'a', array (
						'class' => 'btn btn-success',
						'onclick' => $confirmOnclick
				), btn_confirm ) );
				$queryString [$this->actionKey] = 'index';
				if (isset ( $queryString ['key'] )) {
					unset ( $queryString ['key'] );
				}
				$fa->addChildren ( new HtmlTag ( 'a', array (
						'class' => 'btn',
						'href' => '?' . http_build_query ( $queryString, '', '&' )
				), btn_cancel ) );
				$fieldset->addChildren ( $controlGroup );
				break;
		}

ثم هذا الكود 

if (! empty ( $_POST ) && $_POST ['token'] == $_SESSION [$this->uid] [$_POST ['token_key']] && $this->uid . "_auth_token" . '_' . md5 ( $tokenId ) == $_POST ['token_key']) {
			switch ($_POST ['action_type']) {
				case 'confirm' :
					$error = $this->dataProcessing ();
					if (! empty ( $error )) {
						$errors ['data_processing'] = $error;
					}
					$action = $this->action . '_confirm';
					if (! empty ( $this->validates )) {
						if (! class_exists ( 'AbstractValidator' )) {
							require dirname ( __FILE__ ) . '/validation/AbstractValidator.php';
						}
						if (! class_exists ( 'FormValidator' )) {
							require dirname ( __FILE__ ) . '/validation/FormValidator.php';
						}

						$formValidator = new FormValidator ();
						foreach ( $this->validates as $field => $args ) {
							$type = $args [1];
							$aryType = explode ( '_', $type );
							$class = '';
							if (! empty ( $aryType )) {
								foreach ( $aryType as $t ) {
									if (! empty ( $t )) {
										$class .= ucfirst ( strtolower ( $t ) );
									}
								}
							}
							$class .= 'Validator';

							if (! class_exists ( $class )) {
								require dirname ( __FILE__ ) . '/validation/' . $class . '.php';
							}
							$hidden = new InputHiddenTag ( array (
									'name' => $this->uid . '.' . $field
							) );
							if (isset ( $this->alias [$field] )) {
								$name = $this->alias [$field];
							} else {
								$name = '';
								$tmp = explode ( '.', $field );
								foreach ( $tmp as $t ) {
									$name .= ucfirst ( $t );
								}
							}
							$validator = new $class ( $field, $name, $hidden->getValue () );
							if (method_exists ( $validator, 'init' )) {
								$validator->init ( $args );
							}
							$formValidator->addValidator ( $validator );
						}
						if (! $formValidator->validate ()) {
							$errors = array_merge ( $errors, $formValidator->errors );
							$action = $this->action;
						}
					}
					break;
				case 'save' :
					$editFlag = true;

					if (! empty ( $this->primaryKeys )) {
						foreach ( $this->primaryKeys as $k3 => $v3 ) {
							foreach ( $v3 as $v4 ) {
								if ($k3 == $this->table) {
									if (empty ( $_POST [$this->uid] [$k3] [$v4] ) || trim ( $_POST [$this->uid] [$k3] [$v4] ) == '') {
										$editFlag = false;
										break;
									}
								}
							}
							if ($editFlag == false) {
								break;
							}
						}
					}
					$queryString = $this->queryString;
					$queryString [$this->actionKey] = 'index';
					if (isset ( $queryString ['key'] )) {
						unset ( $queryString ['key'] );
					}
					$req = $this->getData ();

					if ($editFlag == false) {
						if (! empty ( $this->callback ['BEFORE_INSERT'] )) {
							foreach ( $this->callback ['BEFORE_INSERT'] as $callback ) {
								if (isset ( $callback [1] ) && file_exists ( $callback [1] )) {
									require_once $callback [1];
								}
								if (is_callable ( $callback [0] )) {
									$req = call_user_func ( $callback [0], $this, $req );
								}
							}
						}

						$this->insert ( $req, $this->table );

						if (! empty ( $this->callback ['AFTER_INSERT'] )) {
							foreach ( $this->callback ['AFTER_INSERT'] as $callback ) {
								if (isset ( $callback [1] ) && file_exists ( $callback [1] )) {
									require_once $callback [1];
								}
								if (is_callable ( $callback [0] )) {
									call_user_func ( $callback [0], $this, $req, $this->insetId );
								}
							}
						}
						$this->redirect ( "?" . http_build_query ( $queryString, '', '&' ) );
					} else {
						if (! empty ( $this->callback ['BEFORE_UPDATE'] )) {
							foreach ( $this->callback ['BEFORE_UPDATE'] as $callback ) {
								if (isset ( $callback [1] ) && file_exists ( $callback [1] )) {
									require_once $callback [1];
								}
								if (is_callable ( $callback [0] )) {
									$req = call_user_func ( $callback [0], $this, $req );
								}
							}
						}
						$this->update ( $req, $this->table );
						if (! empty ( $this->callback ['AFTER_UPDATE'] )) {
							foreach ( $this->callback ['AFTER_UPDATE'] as $callback ) {
								if (isset ( $callback [1] ) && file_exists ( $callback [1] )) {
									require_once $callback [1];
								}
								if (is_callable ( $callback [0] )) {
									call_user_func ( $callback [0], $this, $req, $this->insetId );
								}
							}
						}
						$this->redirect ( "?" . http_build_query ( $queryString, '', '&' ) );
					}
					break;
				default :
					$action = $this->action;
					break;
			}

شكرا

انشر على الشّبكات الاجتماعية


رابط هذه المساهمة

لا توجد أي إجابات على هذا السؤال بعد


يجب أن تكون عضوًا لدينا لتتمكّن من التعليق

انشاء حساب جديد

يستغرق التسجيل بضع ثوان فقط


سجّل حسابًا جديدًا

تسجيل الدخول

تملك حسابا مسجّلا بالفعل؟


سجّل دخولك الآن