Explorar o código

added update in Zaliczka

Piotr Labudda %!s(int64=9) %!d(string=hai) anos
pai
achega
f1c52fc8d2

+ 1 - 1
SE/se-lib/Core/AclSimpleSchemaBase.php

@@ -411,7 +411,7 @@ class Core_AclSimpleSchemaBase extends Core_AclBase {
   public function buildFromSqlRow($row, $params = []) {
     $object = [];
     $filterCols = $this->getParamCols($params);
-    $object['_raw'] = $row;
+    // $object['_raw'] = $row;
     if (in_array('@instance', $filterCols)) {
       $instanceTable = Core_AclHelper::getInstanceTable($this->getRootTableName());
       $sqlPkFieldName = $this->getSqlPrimaryKeyField();

+ 17 - 7
SE/se-lib/Route/UrlAction/UserProNetMediaZaliczka.php

@@ -63,7 +63,7 @@ class Route_UrlAction_UserProNetMediaZaliczka extends RouteBase {// TODO: UrlAct
 		$acl = ACL::getAclByNamespace("default_db/ZALICZKA/Zaliczka");
 		$schema = $acl->getSimpleSchemaTree();
 		if (!empty($args['updates'])) {
-			throw new Exception("TODO: updates! F." . __FUNCTION__ . " L." . __LINE__);
+			$acl->updateItem($args['updates']);
 		}
 
 		$zaliczkaData = $acl->getItem($args['idZaliczka'], [
@@ -169,15 +169,25 @@ class Route_UrlAction_UserProNetMediaZaliczka extends RouteBase {// TODO: UrlAct
 					$editLink = Request::getPathUri() . "index.php?_route=UrlAction_UserProNetMediaZaliczka&idUser={$idUser}&idZaliczka={$row['ID']}";
 					$editLabel = ('ZaliczkaAktywna' == $instance) ? "Rozlicz / Podgląd" : "Podgląd";
 					$histLink = Request::getPathUri() . "index.php?_route=UrlAction_UserProNetMediaZaliczka&_task=hist&idUser={$idUser}&idZaliczka={$row['ID']}";
+					if (V::get('DBG', '', $_GET)) {
+						return [
+							'Nr' => $row['ID'],
+							'Status' => $row['A_STATUS'],
+							'INSTANCE' => $instance,
+							'L_APPOITMENT_USER' => $row['L_APPOITMENT_USER'],
+							'KWOTA' => $row['KWOTA'],
+							'NIEROZLICZONA_KWOTA' => $row['NIEROZLICZONA_KWOTA'],
+							'#' => '<a href="' . $editLink . '">' . $editLabel . '</a>',
+							'DBG' => '<a href="' . $histLink . '">' . "DBG HIST" . '</a>'
+						];
+					}
 					return [
 						'Nr' => $row['ID'],
-						'Status' => $row['A_STATUS'],
-						'INSTANCE' => $instance,
-						'L_APPOITMENT_USER' => $row['L_APPOITMENT_USER'],
-						'KWOTA' => $row['KWOTA'],
-						'NIEROZLICZONA_KWOTA' => $row['NIEROZLICZONA_KWOTA'],
+						'Typ' => $instance,
+						'Pracownik' => $row['L_APPOITMENT_USER'],
+						'Kwota' => $row['KWOTA'],
+						'Nierozliczona kwota' => $row['NIEROZLICZONA_KWOTA'],
 						'#' => '<a href="' . $editLink . '">' . $editLabel . '</a>',
-						'DBG' => '<a href="' . $histLink . '">' . "DBG HIST" . '</a>'
 					];
 				},
 				$acl->getItems([

+ 24 - 0
SE/se-lib/Schema/DefaultDb/zaliczka/ZaliczkaStorageAcl.php

@@ -184,6 +184,30 @@ class Schema_DefaultDb_zaliczka_ZaliczkaStorageAcl extends Core_AclSimpleSchemaB
     return $id;
   }
 
+  public function updateItem($itemPatch) {
+    $pkField = $this->getPrimaryKeyField();
+    if (!array_key_exists($pkField, $itemPatch)) throw new Exception("Missing primary key");
+    $pk = (int)$itemPatch[$pkField];
+    if ($pk <= 0) throw new Exception("Wrong primary key format");
+    $oldItem = $this->getItem($pk, [
+			'cols' => [
+				'id',
+				'kwota',
+				// 'nierozliczona_kwota',
+				'pozycja',
+				// 'worker',
+			]
+		]);
+    $patch = [];
+    if ($itemPatch['kwota'] != $oldItem['kwota']) $patch['kwota'] = $itemPatch['kwota'];
+    // TODO: doff $itemPatch['pozycja'] != $oldItem['pozycja']
+    if (!empty($patch)) {
+      if (array_key_exists('kwota', $patch)) {
+        DB::getPDO()->update('ZALICZKA', 'ID', $pk, [ 'kwota' => $patch['kwota'] ]);
+      }
+    }
+  }
+
   public function getItem($primaryKey, $params = []) {
     $zaliczkaRaw = DB::getPDO()->fetchAll("
       select t.*

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
SE/static/zaliczka/main.js


Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio